php – Facebook chatbot以“Action Unsuccessful”错误响应持久菜单回发

我的facebook Chatbot的持久菜单工作正常,直到几天前,每当我点击一个持久性菜单项时,每次尝试都会引发一个弹出错误:
行动不成功
向机器人发送消息时出错.
请稍后再试.

偶尔会发生这种情况,我检查过,当发生这种情况时,我的PHP代码方没有收到任何来自Facebook的回发.当没有错误时,回发工作正常.是否有其他人收到此错误?

我的持久性菜单设置如下:

//-----------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);

解决方法:

我有同样的问题.它由以下变化修复:

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

您可能忘记添加事件,并且不允许FB将任何按钮的回发/有效负载发送到服务器.

检查按钮的类型是否正确指定为以下之一:web_url或小写回发.

还要记住,持久性菜单需要根据FB Developers Doc的pages_messaging权限

上一篇:无法加载文件或程序集“Microsoft.WindowsAzure.Storage”或其依赖项之一.运行聊天机器人C#时


下一篇:ICLR2021对比学习(Contrastive Learning)NLP领域论文进展梳理