lonewolf
lonewolf

Reputation: 69

fb messenger bot callback always receiving like message

I am trying to build a messenger bot. I verified a token and linked a page to the bot app. Now the problem is whenever I send a message to the page, the server is getting a JSON response with a "LIKE" message and no message text.

{'object': 'page',
  'entry': 
     [{'time': 1490417055475,
       'messaging': 
         [{'message': {'mid': 'mid.$cAALh2oap5fFhMxj3m1bAdOuaPgvd', 'sticker_id': 369239263222822, 
           'attachments': 
                  [{'payload': {'sticker_id': 369239263222822, 'url': 'https://scontent.xx.fbcdn.net/v/t39.1997-6/851557_369239266556155_759568595_n.png?_nc_ad=z-m&oh=65f8806bcfe45834eb50b60f51cb352d&oe=596142DC'}, 'type': 'image'}], 'seq': 57831},
          'sender': {'id': '1311257182278227'}, 'recipient': {'id': '768737829931919'}, 'timestamp': 1490384301979}], 'id': '768737829931919'}]}

Has anybody experienced this before? I am completely stuck because of this behavior from messenger API.

Upvotes: 1

Views: 463

Answers (1)

mraaroncruz
mraaroncruz

Reputation: 3809

I'm going out on a limb here because there isn't very much information in the question.

That message isn't a "LIKE" message. It is an image message that is created by someone (OP) clicking, tapping or click-hold/tap-hold the thumbs up button in the chat input area.

thumbs up button

What may be happening is that you originally send a thumbs up to the chatbot and your app answered with something other than a 200 HTTP response. When this happens, facebook waits and sends the response (in this case the thumbs up) in about a minute. If there is another non-200 response, it will repeat.

If I'm right, a solution would be to just swallow the error (if you have exceptions in your programming language, just rescue and move on) and respond with a 200.
This should make Facebook think you're good to go and they will deliver all the backed up messages after the positive ressponse. Then remove the error swallowing and you should be receiving messages as they are sent from Facebook, unless you are erroring out again.

Upvotes: 2

Related Questions