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

大城市里の小女人 提交于 2019-12-05 16:31:44

问题


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.


回答1:


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.




回答2:


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




回答3:


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)




回答4:


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?



来源:https://stackoverflow.com/questions/38007290/facebook-messenger-bot-how-to-disable-bot-and-allow-human-to-chat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!