Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Messenger Bot - How to disable bot and allow human to chat

so this is something I've been trying to think through for about 16 hours. I am coding with PHP / CuRl / etc - the bot works and everything is fine. My current issue is figuring out how to disable the bot and allow a human to begin chatting with the customer/sender.

Has anyone successfully, created a route for this ? I mean it's pretty hard from what I see, you'd have to disable etc etc. A lot of effort for my clients.

Thanks for any input.

like image 390
Michael Self-Made Avatar asked Jun 24 '16 06:06

Michael Self-Made


People also ask

How do you reset Messenger bot?

Here's how you find the menu within the bot. If you ever need to start again or reset the bot, just send it a message saying “reset” or “restart”. And you can manage your subscriptions by tapping one of the choices on the menu (which is symbolised by the three horizontal lines).


4 Answers

Facebook has rolled out a "Handover Protocol" which is supposed to facilitate a combined human/bot Messenger implementation.

https://developers.facebook.com/docs/messenger-platform/handover-protocol

It is a little unclear what actually occurs in step 5:

Pass thread control: At some point in the conversation, a user may choose to do something like interact with a live agent. To handle this, pass thread control from the Primary Receiver to the Secondary Receiver. The Secondary Receiver will receive a messaging_handovers webhook event to notify it that is now controls the conversation.

This doesn't actually disable the bot (as the OP requested), and isn't in the control of the Page owner but rather of the user. It seems FB envisions the user typing something like 'I would like to chat with a human' triggering the bot to pass control...but it would be nice to let the page owner simply put the app in standby and handle the messages herself.

like image 90
laloumen Avatar answered Oct 27 '22 23:10

laloumen


Once you recognize someone wants to speak to a human, set a flag that disables all actions of your bot to on.

Then, have your bot message you, or whoever will respond, that a user ID needs responding to. Have your bot continue to send all messages received from them back to you until you enable the bot again.

Create some sort of way for your bot to interact with you that allows you to send a message to a specific user, and a way to once again enable the bot interaction with the user.

Probably something like "sendMessage104012301230'Hi, sorry you couldn't find [etc]', and enableUser104012301230

There may be a better way, but those are some thoughts on how I'd do it

like image 33
user2322082 Avatar answered Oct 27 '22 23:10

user2322082


If you enable messages echo, whenever a human respond using the page, a echo post is sent, and inside entry->messaging->message there's no app_id.

You can use that information to disable bot replies for a certain period, or disable indefinitely until you enabled is with some admin command (that's how I'm doing)

like image 2
Pablo Avatar answered Oct 28 '22 01:10

Pablo


I thought a solution could be to label the message as "unsolved". Another solution could be to have the bot mark the conversation as unread. Does anyone know if it is possibile to add a label to a conversation or mark as unread through API?

like image 1
Freerider Avatar answered Oct 27 '22 23:10

Freerider