Skip to main content

Automatic End Live Chat Function

For some platform like WhatsApp Business API, if the user is idled for more than 24 hours, the agent will not be able to send any messages to the user. As a result, it will be quite useful to set up a function to automatically end any live chat which the user has been idling for more than 24 hours.

What is your Result?

Archive Button on Slack
Archive Button on Slack
Auto End Live Chat Notification on Slack
Auto End Live Chat Notification on Slack
Changed Status for Picked Ticket
Changed Status for Picked Ticket
Changed Status for Unpicked Ticket
Changed Status for Unpicked Ticket
note

Please remember to connect your Slack Channel on Stella before testing for the result.

Sample Tree Structure

Tree Structure for Auto End Live Chat
Tree Structure for Auto End Live Chat

Getting Hands-on

Enter your Bot Builder and starting building your tree.

Create a Tree Node - Auto End Live Chat

  1. You could use any tree on the Inlet Channel for implementation. Create a Tree Node and name it as "Auto End Live Chat".

  2. Create a Pre-action for sending the Archive Button during the ending of live chat with the following code:

return new Promise(async (resolve, reject) => {
try {
if (this.member.group) {
await this.sendMessageToOutletGroup({
groupId: this.member.group,
response: {
type: "BUTTON",
text: "用户已离开专人对话,你要archive这个对话吗?",
buttons: [{
type: "postback",
title: "Archive Now",
payload: "ARCHIVE"
}]
},
})
}
resolve({
member: this.member
})
} catch (e) {
reject(e)
}
})

  1. Create a second Pre-action for ending live chat with the following code :
return new Promise(async (resolve, reject) => {
try {
this.member = await this.inletEndLiveChat({
channel: this.channel,
member: this.member,
options: {
recallRelayMessage: true
}
})
this.lodash.set(this.member, "group", null)
resolve({
member: this.member
})
} catch (e) {
reject(e)
}
})
  1. Create a basic Response for notifying the user that the live chat has been ended.

  2. Save the Tree Node.

  3. Head to your Inlet Channel and find Live Chat Settings.

Tree Structure for Auto End Live Chat
Tree Structure for Auto End Live Chat
  1. Add and set up the Idle Timer. The timer will start the count down if the user is idled.

  2. Locate and select the "Auto End Live Chat" Tree Node,

  3. Save the settings in Channel.

  4. Test and see if you can produce the expected outcome.