How to identify when user disconnect from Bot

Hi Team,

I want to implement following scenario.

I am chatting with Bot. All of sudden because of some issue I disconnected from Bot (reason may be I closed the Bot Interface, Internet Connection drops etc). In this case I want to generate SalesForce Case with Status as Cancelled. What are the different ways I can achieve it?
Can I read the session between conversation?
How do I identify that Session is no more alive?
Can I write some handlers or Webhook around it?

Please reply something on this topic. I am eagerly waiting for it.

Hi @praful_dhone,

Please find the below snippet in the chatWindow.js that will get triggered when the close button on the chat window is clicked.

_chatContainer.off(‘click’, ‘.close-btn’).on(‘click’, ‘.close-btn’, function (event) {
$(’.recordingMicrophone’).trigger(‘click’);
if (ttsAudioSource) {
ttsAudioSource.stop();
}
me.isTTSOn = false;
me.destroy();
if (_ttsContext) {
_ttsContext.close();
_ttsContext = null;
}
if (me.config.multiPageApp && me.config.multiPageApp.enable) {
me.removeLocalStoreItem(‘kr-cw-state’);
me.removeLocalStoreItem(‘kr-cw-uid’);
me.config.botOptions.maintainContext = false;
}
});
You can write the script as per your requirement in this function so that it will get executed when the chat window is closed.

Also, you can use botKit SDK functions which will be helpful to achieve your requirement.
https://developer.kore.ai/docs/bots/sdks/functions-for-the-botkit-sdk/#sdkcloseConversationSession

Let us know if you need any further infromation.

Regards,
Yoga Ramya