Back to BotKit SDK OverviewThe BotKit SDK lets you handle Platform events to customize conversation behavior. Register handlers for the following events in your bot’s Node.js module.Supported events:
Call at completion to send updated message and context back to the Platform
{ "message": "message sent by the bot to the user", "taskId": "Dialog task Id", "nodeId": "current node id in the dialog flow", "channel": "channel name", "context": "context object"}
Example — Route to live agent or forward to bot:
function onUserMessage(requestId, payload, callback) { var visitorId = payload.context.session.UserContext._id; var entry = _map[visitorId]; if (payload.message === "clearagent") { sdk.clearAgentSession(payload); } if (entry) { // Route to live agent var formdata = {}; formdata.secured_session_id = entry.secured_session_id; formdata.license_id = config.liveagentlicense; formdata.message = payload.message; return api.sendMsg(visitorId, formdata) .catch(function(e) { delete userDataMap[visitorId]; delete _map[visitorId]; return sdk.sendBotMessage(payload, callback); }); } else { return sdk.sendBotMessage(payload, callback); }}
The Platform emits real-time Contact Center Events to the BotKit channel via onEventNode. These events cover agent actions and conversation lifecycle changes.
These events are only emitted for bots connected to the BotKit channel.
Triggered when an agent transfers the conversation to another agent or queue.Payload fields:sessionId, fromAgentId, toAgentId or toQueueId, transferSummary, timestamp