Skip to main content
Back to BotKit SDK Overview The BotKit SDK provides functions for controlling message flow, managing agent sessions, and working with async webhook responses. Available functions:

sdk.sendUserMessage

Sends a message to the user. Use inside on_bot_message to modify the bot’s reply before delivery. Syntax:
Payload:
When spell correction is unavailable:
Meta tags (v8.0+) — Add to payload to tag the conversation:
Examples:

sdk.sendBotMessage

Sends a message to the bot. Use inside on_user_message to modify or forward the user’s message. Messages are validated: max 3000 characters total, max 1200 characters per word. Syntax:
Payload:
Examples:

sdk.AsyncResponse

Sends an HTTP 202 to the Platform to indicate an async webhook response is in progress. Call sdk.respondToHook(payload) when the response is ready. Syntax:
Example — Async cab booking:

sdk.respondToHook

Sends the final webhook response to the Platform after async processing completes. Syntax:
Payload:
Example:

sdk.registerBot

Registers a bot and its event callbacks. Create one Node.js file per bot and export the required variables. Module structure:
Register the bot:
Example:

sdk.saveData

Saves payload data to Redis by requestId. Use during async webhook handling to persist state between the initial event and the final response. Syntax:
Example:

sdk.getSavedData

Reads payload data from Redis by requestId. Use when responding to an async webhook to retrieve the saved state. Syntax:
Example:

sdk.getMessages

Retrieves the conversation history between the bot and user in reverse chronological order. Supports pagination. Syntax:
Parameters:
ParameterDescription
stream_idBot ID (from Config Settings)
user_idUser whose history to fetch
skipNumber of messages to skip
limitNumber of messages per page
channelType(Optional) channel filter
Example:

sdk.clearAgentSession

Clears the agent session and re-establishes the conversation with the bot. Call this when the live agent closes the chat (triggered by a chat_closed event from the third-party provider). Syntax:
Example:

sdk.startAgentSession

Notifies the Platform that an agent transfer is in progress. After calling this, the data object received by BotKit will have agent_session: true. When sdk.clearAgentSession is called, the Platform sets it back to false. Syntax:
Example:

sdk.resetBot

Clears the bot context and silently discards the current task. Use when a user explicitly requests a reset. Syntax:
Example:

sdk.extendRequestId

Extends the time window for BotKit to send messages to the Platform. Use during prolonged agent transfer sessions where the Platform might stop receiving messages. Syntax:
Extension is ineffective after 15 minutes of conversation inactivity. An inactive session resets agent_transfer mode regardless.
Example:

sdk.skipBotMessage

Skips a specific bot message and proceeds to the next dialog step without waiting for BotKit delivery. Syntax:
Example:

sdk.skipUserMessage

Skips a specific user message and proceeds to the next dialog step without waiting for BotKit confirmation. Syntax:
Example:

sdk.closeConversationSession

Closes the current conversation session. Syntax:
Example: