Facebook聊天机器人以“动作失败”响应。永久菜单回发错误 [英] Facebook chatbot responds with "Action Unsuccessful" error to Persistent Menu postback
问题描述
直到几天前,我的facebook Chatbot的持久菜单仍能正常工作,当我单击持久菜单项时,每尝试几次,它就会弹出一个错误:
操作不成功
将您的消息传递给机器人时出错。
,请稍后再试。
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.
这种情况偶尔发生,我检查了这种情况,我的PHP代码端没有收到来自Facebook的任何回发。如果没有错误,则回发可以正常进行。还有其他人收到此错误吗?
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);
推荐答案
我遇到了同样的问题。它通过以下更改得到修复:
I had the same problem. It was fixed by the following changes:
App settings -> [Products] Messenger -> Settings -> Webhooks -> Edit events -> Add messaging_postbacks
您可能已忘记添加事件,并且不允许FB发送任何按钮的回发/有效负载到服务器。
You may have forgotten to add the event and FB is not allowed to send any buttons' postback / payload to the server.
请彻底检查按钮的类型是否正确指定为以下之一: web_url
或后退
小写。
Check thoroughly if the type of the buttons is correctly specified as one of the following: web_url
or postback
in lower case.
还请注意,持久菜单要求 pages_messaging许可
根据 FB开发人员文档
Have in mind also that the persistent menu requires pages_messaging permission
according to FB Developers Doc
这篇关于Facebook聊天机器人以“动作失败”响应。永久菜单回发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!