0

So I have created Messenger bot. Is there a way to receive webhook when someone who was interacting with bot has blocked it? Similar to how you can set up webhook when someone uninstalls facebook app.

When a user first interacts with the bot I store his information in the database. If he decides to block the bot, I want to delete that row from the database so receiving messenger_id would be completely enough.

I read through FB docs but did not find anything useful. Would appreciate if someone could help.

Roham Rafii
  • 2,929
  • 7
  • 35
  • 49
Kārlis Janisels
  • 1,265
  • 3
  • 18
  • 41

1 Answers1

1

You will receive an error code when you try to message the user from your bot. Probably something similar to this:

{
  "error": {
    "message": "This Person Cannot Receive Messages: This person isn't receiving messages from you right now.",
    "type": "OAuthException",
    "code": 10,
    "error_subcode": 2018108,
    "fbtrace_id": "BLBz/WZt8dN"
  }
}

Try going through your response logs finding that user PSID to see the exact error you are getting, but it should be very similar to the above.

So what you have to do is update the user when you get a response like this consistently, perhaps set a counter or build a rule for when you decide is enough to remove the user form your DB or disable. More info on the errors here: https://developers.facebook.com/docs/messenger-platform/reference/send-api/error-codes