Facebook chatbot responds with “Action Unsuccessfu

2019-06-25 17:07发布

问题:

My facebook Chatbot's persistent menu was working fine until a few days ago, once in every few tries when I click on a persistent menu item it would raise a popup error : Action Unsuccessful There was an error delivering your message to the bot. Please try again later.

This happens sporadically, and I checked that when this happens my PHP code's side didn't receive any postback from facebook. When there's no error the postback works fine. Is anyone else getting this error?

My Persistent menu is setup as such:

//-----------Persistent Menu
$url = 'https://graph.facebook.com/v2.6/me/messenger_profile?access_token='.$access_token;
$ch = curl_init($url); 

$jsonData = '{
  "persistent_menu":[
    {
      "locale":"default",
      "composer_input_disabled": false,
      "call_to_actions":[
            {
              "title":"View in Chinese",
              "type":"postback",
              "payload":"mainMenu"
            },
            {
              "title":"View in English",
              "type":"postback",
              "payload":"mainMenuEN"
            }


      ]
    },
        {
      "locale":"zh_TW",
      "composer_input_disabled": false,
      "call_to_actions":[
            {
              "title":"View in Chinese",
              "type":"postback",
              "payload":"mainMenu"
            },
            {
              "title":"View in English",
              "type":"postback",
              "payload":"mainMenuEN"
            }

      ]
    },      
        {
      "locale":"en_US",
      "composer_input_disabled": false,
      "call_to_actions":[
            {
              "title":"View in Chinese",
              "type":"postback",
              "payload":"mainMenu"
            },
            {
              "title":"View in English",
              "type":"postback",
              "payload":"mainMenuEN"
            }

      ]
    }
  ]
}';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);

回答1:

I had the same problem. It was fixed by the following changes:

App settings -> [Products] Messenger -> Settings -> Webhooks -> Edit events -> Add messaging_postbacks

You may have forgotten to add the event and FB is not allowed to send any buttons' postback / payload to the server.

Check thoroughly if the type of the buttons is correctly specified as one of the following: web_url or postback in lower case.

Have in mind also that the persistent menu requires pages_messaging permission according to FB Developers Doc



回答2:

If you already have messaging_postbacks enabled but are still getting this error:

The Page Access Token you are using probably needs to be updated in your webhook.

Go back to developer app dashboard. Select Messenger >> Settings. Scroll down to the "Token Generation" section:

Select your page from the dropdown, and copy the new access token for use in your webhook.

I had the same issue and this worked for me after searching everywhere for an answer.