A very popular use case for chatbots is the integration of the chat window into a website or web application. However, a challenge with this setup is when the user abandons a chat conversation by closing the browser window. In this case, Oracle Digital Assistant stops the Web Channel conversation after a predefined period of time, which usually is not within seconds but mostly within the 10s of minutes.
However, what if the user was interacting with a human agent through the bot conversation when deciding to the leave the conversation by closing the browser window? And what is the impact?
Oracle Digital Assistant has no way to tell when the user closes the browser window. This leads to the agent integration connection to stay open until the session expires, which however then means that the overall number of connections to the human agent backend system doesn't match the number of active connections until the session expired.
Another impact is the situation the agent is in. Because the agent is not aware of he user leaving the conversation, he or she may continue checking if the user s still there and spend time waiting until they eventually decide the user may no longer be online.
This article describes a strategy for ending the interaction between a user and an agent when the user leaves the bot conversation by closing the browser window.
Solution
The solution to the problem is easier to find after formulating the problem statement differently: “How can I, upon channel closure, notify my agent component and close the existing connection?”
Before moving on, a word of caution: Important Note: The solution in this article works for web as the messenger channel. Unfortunately too, browsers behave differently, so that beside of this solution being limited to the use with web messengers, the code may require tweaking for other browsers used by bot users. So, testing is your friend. If you use the Oracle client SDK for Android and iOS, then you may find similar methods to call.
So, lets have a look at one possible solution (the one in focus for this article). The screen shot below shows the code needed to alert the human agent that the user has left the conversation
- The left hand side of the image below shows the JavaScript code for the solution. The window.onBeforeUnload function is called when the browser gets closed by the user. In the function body, a message gets send to the bot to indicate the end of the conversation. For this article, the closing message was chose as "closedConnection”. However, the string to send can be anything you like as long as you follow the next step.
- In the bot dialog flow (right side of the picture above), an exit keyword (or more if you want to support different strings that can be used by a user) that exactly matches the message defined in the previous step. Be careful here as the message needs to be exactly the same, as our goal is that it will be considered as an exit keyword. With the JavaScript message sent, it is basically as if the the user typed “closedConnection”
With the setup above the sequence of actions can be summarized as shown below
- User exits the channel
- The Oracle Digital Assistant JavaScipt Client Bots API sends the defined message to the bot. Since a live agent conversation is on, the message eventually gets posted to the conversation
- The message matches an exit utterance and thus forces the bot-user conversation to end
And here is the “before” and “after” effect in pictures
As you can see in the human agent message console, the BEFORE image does not show any indication that the user has left the conversation. The AFTER image however. shows the closing message as well as the system disconnecting.
Related Content
Best Practices and Tips for Conversational Design and User Experience in Oracle Digital Assistant
Adding Alexa as a Conversation Channel to your Oracle Digital Assistant Chatbot