- sdk.sendUserMessage
- sdk.sendBotMessage
- sdk.AsyncResponse
- sdk.respondToHook
- sdk.registerBot
- sdk.saveData
- sdk.getSavedData
- sdk.getMessages
- sdk.clearAgentSession
- sdk.startAgentSession
- sdk.resetBot
- sdk.extendRequestId
- sdk.skipBotMessage
- sdk.skipUserMessage
- sdk.closeConversationSession
sdk.sendUserMessage
Sends a message to the user. Use insideon_bot_message to modify the bot’s reply before delivery.
Syntax:
sdk.sendBotMessage
Sends a message to the bot. Use insideon_user_message to modify or forward the user’s message. Messages are validated: max 3000 characters total, max 1200 characters per word.
Syntax:
sdk.AsyncResponse
Sends an HTTP 202 to the Platform to indicate an async webhook response is in progress. Callsdk.respondToHook(payload) when the response is ready.
Syntax:
sdk.respondToHook
Sends the final webhook response to the Platform after async processing completes. Syntax:sdk.registerBot
Registers a bot and its event callbacks. Create one Node.js file per bot and export the required variables. Module structure:sdk.saveData
Saves payload data to Redis byrequestId. Use during async webhook handling to persist state between the initial event and the final response.
Syntax:
sdk.getSavedData
Reads payload data from Redis byrequestId. Use when responding to an async webhook to retrieve the saved state.
Syntax:
sdk.getMessages
Retrieves the conversation history between the bot and user in reverse chronological order. Supports pagination. Syntax:| Parameter | Description |
|---|---|
stream_id | Bot ID (from Config Settings) |
user_id | User whose history to fetch |
skip | Number of messages to skip |
limit | Number of messages per page |
channelType | (Optional) channel filter |
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 achat_closed event from the third-party provider).
Syntax:
sdk.startAgentSession
Notifies the Platform that an agent transfer is in progress. After calling this, thedata object received by BotKit will have agent_session: true. When sdk.clearAgentSession is called, the Platform sets it back to false.
Syntax:
sdk.resetBot
Clears the bot context and silently discards the current task. Use when a user explicitly requests a reset. Syntax: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.