0

I have been trying to figure this out but have had no luck. A search got me this: Facebook Messenger Bot - How to disable bot and allow human to chat

I am using Python but can successfully receive callbacks (and messages echoes) so I can retrieve the result when someone selects "other" in my bot but I haven't figured out how to disable it to allow a human to reply (and reenable it later).

Anybody has done that?

3 Answers3

1

I believe this is currently a beta feature with the Hand-Over Protocol: https://developers.facebook.com/blog/post/2017/04/18/messenger-platform-2.0/

aprouja1
  • 1,800
  • 8
  • 17
0

Try using boolean logic. It worked for my NodeJS app. It was something like this:

...
var botActive = true;
...
app.post('/webhook/', function (req, res) {
    let messaging_events = req.body.entry[0].messaging
    for (let i = 0; i < messaging_events.length; i++) {

        if (botActive == false) {
            // Add some conditions to wake up your bot if need be
        }

        if (botActive) {
            // If a message matches what you're looking for, make the bot respond.
            // If message doesn't match, send a default message (e.g. "The humans will get back to you.") and set botActive to 'false'
        }
    }
});

For python, look at how to edit global variables. I know global variables are messy, but you have good reason to edit this one boolean and remember it in the future.

Chege
  • 353
  • 4
  • 9
0

Currently(13 July 2017), there is no solution on the Facebook side; but it is possible to implement a logic in your code base.

You can create a control panel that can update user_id and bot_enabled. And then when you receive a webhook from Facebook, you can check if the bot response enabled for that sender - aka: user_id.

mustafaturan
  • 2,171
  • 21
  • 17