Skip to main content
The BotImplementation class (exported as Bot) implements the runtime behavior of a bot, including event handlers, action implementations, and lifecycle hooks.

Constructor

BotImplementationProps

object
required
Action handler implementations.
object
required
Plugin implementation instances.
function
Registration handler called when bot is registered.

Handler Registration

Use the on property to register event, message, and hook handlers:

Message Handlers

Handle incoming messages from channels:
Handler Props:
Message
The incoming message with type and payload.
User
The user who sent the message.
Conversation
The conversation containing the message.
Event
The event that triggered the message.
BotSpecificClient
Type-safe API client.
BotContext
Bot context with configuration and IDs.
BotLogger
Logger instance for the bot.
WorkflowProxy
EXPERIMENTAL - Workflow management API.

Event Handlers

Handle custom and integration events:
Handler Props:
Event
The event with type and payload.
BotSpecificClient
Type-safe API client.
BotContext
Bot context.
BotLogger
Logger instance.
WorkflowProxy
EXPERIMENTAL - Workflow API.

State Expiry Handlers

Handle state expiration events:

Hook Handlers

Intercept and modify operations before/after execution:

Before Hooks

After Hooks

Workflow Handlers

EXPERIMENTAL - Handle workflow lifecycle events:

Action Implementations

Implement actions defined in the bot definition:
Action Handler Props:
ActionInput
Type-safe action input matching the definition schema.
BotSpecificClient
Type-safe API client.
BotContext
Bot context with configuration.
BotLogger
Logger instance.
WorkflowProxy
EXPERIMENTAL - Workflow API.

Methods

start

Start the bot HTTP server:
Example:

Properties

RequestHandler
HTTP request handler for the bot.
ActionHandlers
Map of action implementations.
MessageHandlers
Map of message handler arrays.
EventHandlers
Map of event handler arrays.
HookHandlers
Map of hook handler arrays.

Complete Example

index.ts

See Also