我的聊天机器人运行良好,但我在调试欢迎消息功能时遇到了麻烦,因为它仅在发起对话时显示(尽管我很确定在同事手机上尝试过它不起作用)。如何重置我的聊天,以便将我视为与之交互的新用户?
这是我目前受欢迎的 PHP 脚本
<?php
function webhook() {
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'MYTOKEN') {
echo $challenge;
}
$input = json_decode(file_get_contents('php://input'), true);
$sender = $input['entry'][0]['messaging'][0]['sender']['id'];
$welcomejson = welcomemessage();
welcomesend($json);
function message() {
$json = '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message":{
"text":"Welcome to My BOT!"
}
}
]
}';
return $json;
}
function send($json) {
$url = 'https://graph.facebook.com/v2.6/MYPAGEID/thread_settings?access_token=MYTOKEN';
//Initiate cURL.
$ch = curl_init($url);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
//Execute the request
$result = curl_exec($ch);
}
尝试这个:
- 在桌面浏览器中打开 Facebook 并转到链接到您的即时通讯机器人的页面
- 按“留言”
- 在消息弹出窗口/讨论中选择“选项”(齿轮图标)
- 选择“删除对话...”并在确认提示中说出“删除对话”
- 再次选择“消息”
- 选择“开始”
步骤 4. 确实会删除您与页面/应用程序的聊天历史记录,因此请小心。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)