-1

I am creating a customer support bot using Ms botframework v4 with nodeJS and directline API 3.0. A customer would talk to the bot and on request, the conversation would be handed over to an agent. If the customer requested to talk to a bot, the customer will wait until the agent becomes available. I want to check if the customer is still active before the agent sends a message to him/her.

wireframe of the bot and the webiste As you can see in the image Jack is in the queue I want to find out a way to check if Jack is still waiting, or he close the window and no longer waiting.

1 Answers1

0

Check out this SO solution I provided. The request is similar to yours in that the OP wants to know how the bot can be notified if a user exits.

The short answer is to use an event listener. Before the window (that houses the web chat instance) is closed, an event is fired. This event is picked up by web chat which sends an activity (message, event, or other) to notify that bot.

From this point, you simply need to forward the notification to the agent that the user has exited the conversation.

Hope of help!

Steven Kanberg
  • 6,078
  • 2
  • 16
  • 35
  • so what would happen when the user get disconnected? The event is never fired and the user still exists... – emp Jul 20 '20 at 20:20
  • Technically, the OP didn't ask that, so I didn't provide a solution for that scenario. That being said, Web Chat doesn't provide functionality for checking if a user is still online. Firing an event on store action `DIRECT_LINE/DISCONNECTED` is only caught by the bot if the user reconnects (assuming the host's Web Chat code accounts for that) largely because the user is disconnected before anything client-side can fire to notify the bot. – Steven Kanberg Jul 20 '20 at 23:57
  • Simplest solution is to query the user if they are still logged in and, if they don't respond, terminate the session and notify the bot. Or, set a timer and if no user activity happens within a set amount of time, assume they aren't present and terminate the session. It may be overkill, but something like the [toast notification](https://github.com/microsoft/BotFramework-WebChat/blob/master/samples/05.custom-components/i.notification/README.md) could also be used to inform the user they will be logged off after a set amount of time with no activity. – Steven Kanberg Jul 21 '20 at 00:03