Facebook Chat Bot - 如何测试欢迎信息?

Lee*_*man 6 php facebook drupal-7 facebook-messenger

我的聊天机器人工作得很好,但是我在调​​试欢迎消息功能时遇到了问题,因为它只在会话启动时出现(虽然我很确定它在同事手机上尝试过它并不起作用).如何重置聊天,以便将我视为与之交互的新用户?

这是我目前欢迎的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);
}
Run Code Online (Sandbox Code Playgroud)

exampleofissue

ots*_*tso 17

试试这个:

  1. 在桌面浏览器中打开Facebook,然后转到链接到messenger bot的页面
  2. 按"留言"
  3. 在消息弹出/讨论中选择"选项"(cog图标)
  4. 选择"删除对话..."并在确认提示中说"删除对话"
  5. 再次选择"消息"
  6. 选择"开始使用"

第4步.真的删除你使用页面/应用程序的聊天记录,所以要小心.

  • 我认为iOS Messenger中存在一个错误,因为"入门"按钮仅出现在桌面而非移动设备上. (2认同)