Facebook 聊天机器人 - 如何测试欢迎信息? [英] Facebook Chat Bot - How do I test the welcome message?

查看:28
本文介绍了Facebook 聊天机器人 - 如何测试欢迎信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的聊天机器人运行良好,但我在调试欢迎消息功能时遇到了问题,因为它仅在发起对话时显示(尽管我很确定在同事的电话上尝试过它没有工作).如何重置我的聊天,让它将我视为与之交互的新用户?

My chat bot is working great but I am having trouble debugging the Welcome message functionality because it only shows up when a conversation is initiated (although i'm pretty sure it's not working having tried it on a colleagues phone). How do I reset my chat so it sees me as a new user interacting with it?

这是我现在欢迎的 PHP 脚本

This is my welcome PHP Script at the moment

<?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);
}

推荐答案

试试这个:

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

第 4 步.确实会删除您与页面/应用程序的聊天记录,所以要小心.

Step 4. really deletes the chat history you are having with the page/app so beware.

这篇关于Facebook 聊天机器人 - 如何测试欢迎信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆