2
votes

I have a bot that I've built and deployed to Azure. All is working great. At the moment we are only targeting Facebook Messenger.

The scenario I need to handle is during a converstion between a user and the bot, the owner of the page may step into a conversation.

At this point I want the bot to stop responding and allow the page owner to have the conversation with the user.

I can't seem to find much documentation talking about this simple scenario, most scenarios talk about handing off a conversation to a team of customer support people. Which is a much more sophisticated scenario.

How can I achieve this?

I did try setting the bot as the Primary receiver on the page and set the Inbox as the Secondary receiver. The problem with this approach is that it marks all the messages and conversations as Done and moved them into the page owners Done inbox. This isn't the scenario we want.

Has anyone handled a similar situation?

I honestly cannot tell how this could work without having the primary/secondary responders setup thus enabling thread control to be passed between the two. Although I hope I'm wrong and there is a simple approach / solution.

Possible Solution

One technique I'm investigating is related to this:

https://github.com/palindromed/Bot-HandOff/blob/master/handoff.ts

Since our bot doesn't really have anything to handoff too I just want the bot to stop responding to messages when a page admin dives in and sends a message to the user.

I kind of bot muter middleware. The current trick here is going to be detecting that a particular user is a page admin.

1
I can see that you are aware of the Messenger Platform's Handover Protocol. It seems like that would be the way to go, and if you're experiencing a problem with messages getting sent to the Done folder then that sounds like a Facebook issue. - Kyle Delaney
Since it sounds like all you want to do is allow an admin to turn off a bot, perhaps there is a way to do that on the Bot Framework side. I wouldn't call it simple, though. You'd need to set up some kind of web service that accesses the bot's user data for the user that you want to talk to, and then set a flag that the bot can read to know not to respond to activities from that user. - Kyle Delaney
Supposing you wanted that action to be triggered by an admin stepping into a conversation rather than forcing the admin to specifically remember to turn the bot off, perhaps you could use a message_deliveries webhook. That would work for turning the bot off, but not if you wanted to turn the bot back on again. - Kyle Delaney
To be honest I had to give up as a lot of Facebook web hook events seen to not get delivered. I've opened a big on the GitHub repo. But yes your points are all correct. We went with Handoff for now with the bot escalating by moving the message to the inbox on Facebook. - Jammer

1 Answers

3
votes

It turns out the Bot Framework connector was not set up to forward the events that are necessary for working with the Messenger platform's handover protocol, but recent updates have fixed this. I have written a blog post explaining everything you need to know about the handover protocol: https://blog.botframework.com/2019/06/03/using-the-facebook-messenger-handover-protocol-with-the-microsoft-bot-framework/