我的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);
答案 0 :(得分:6)
我遇到了同样的问题。它由以下变化修正:
App settings -> [Products] Messenger -> Settings -> Webhooks -> Edit events -> Add messaging_postbacks
您可能忘记添加事件,并且不允许FB将任何按钮的回发/有效负载发送到服务器。
彻底检查按钮的类型是否正确指定为以下之一:web_url
或postback
小写。
另请注意,根据FB Developers Doc
,持久性菜单需要pages_messaging permission
答案 1 :(得分:1)