Triggering CSAT after session closure using BotKit

Hello Team,

There is a use where we need to present CSAT survey only during the session closure rather than showing after FAQ or end of Dialog task. How can we achieve this step using the Botkit?

Hello team,

Can anyone please respond?

Hello Lucifer,

Welcome to Kore.ai Community.

For the Approach with BotKit SDK

Use the on_event Hook in BotKit

Kore.ai BotKit emits an event when a session or task ends:

  • The on_event handler is triggered when a dialog, FAQ, or session ends.

In your BotKit app, you can capture this event:

sdk.on_event = function(requestId, data, callback) {
  // Check if this is session closure
  if (data.event && data.event.eventType === "endDialog") {
    // Trigger your CSAT survey logic here
    sendCSATSurvey(requestId, data, callback);
  } else {
    callback();
  }
};

Then define your custom function:

function sendCSATSurvey(requestId, data, callback) {
  // Post a CSAT survey message
  const csatMessage = {
    type: "message",
    messages: [
      {
        type: "quickReplies",
        text: "How would you rate your experience?",
        quickReplies: ["😊 Good", "😐 OK", "😞 Bad"]
      }
    ]
  };
  
  return sdk.sendBotMessage(csatMessage, callback);
}

This lets you inject your CSAT survey only on session close events, independent of where in the dialog flow the session ends.

Note:

Kore Platform CSAT Settings

Ensure the CSAT survey is not auto-triggering immediately based on built-in settings in the Kore.ai platform, otherwise the BotKit message might duplicate it.

You can configure the default CSAT survey behavior under:
Bot Builder β†’ Configure β†’ CSAT Settings

This might include toggles like:

  • Only trigger CSAT on agent-closed sessions
  • Exclude CSAT after inactivity closure
    (Newer platform releases support these toggles)

So before handling through code:
Disable default survey if you want full control via BotKit

When this Works

:check_mark: You are using BotKit SDK as middleware
:check_mark: You subscribe to on_event or a custom event
:check_mark: The survey injection is controlled by code, not by platform automatic survey flow

When this Cannot Work

If your bot is purely built using:

  • Platform-only dialog flow
  • No BotKit implementation
    Then you cannot trigger custom CSAT on session end beyond what the platform configuration allows β€” you will need to adjust CSAT triggers in config instead.

Example Use Case of Event Detection

Here’s how the Kore.ai BotKit SDK defines events including session close:

sdk.on_event = function(requestId, data, callback) {
  // eventType could be 'endDialog', 'endFAQ', etc.
  console.log("Event received: ", data.event.eventType);
  callback();
};

Using this, you can add custom logic only when a session fully ends.

Hi Srujan,

Thanks for your response. And we have to save these CSAT to show to the client just like the Feedback Dashboard we have. But if I go with this approach, we cannot save the csat and show it as a dashboard right?