Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook chatbot responds with "Action Unsuccessful" error to Persistent Menu postback

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);
like image 390
Hofuzz Avatar asked Jan 28 '23 00:01

Hofuzz


1 Answers

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

like image 179
Galya Avatar answered Feb 13 '23 06:02

Galya