gpt4 book ai didi

php - Facebook 聊天机器人以 "Action Unsuccessful"错误响应持久菜单回发

转载 作者:可可西里 更新时间:2023-10-31 22:08:55 29 4
gpt4 key购买 nike

直到几天前,我的 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 或小写的 postback

还请记住,根据 FB Developers Doc,永久菜单需要 pages_messaging 权限

关于php - Facebook 聊天机器人以 "Action Unsuccessful"错误响应持久菜单回发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50675764/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com