Facebook Chat Bot - 如何测试欢迎讯息? [英] Facebook Chat Bot - How do I test the welcome message?
本文介绍了Facebook Chat Bot - 如何测试欢迎讯息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的聊天机器人工作非常好,但是我无法调试欢迎消息功能,因为只有当对话开始时才会显示(虽然我很确定它没有在同事手机上尝试过)。如何重新设置聊天功能,让我看到一个新的用户与之交互?
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);
}
推荐答案
尝试这样:
- 在桌面浏览器中打开Facebook,点击链接到您的信使机器人页面
- 按消息
- 在消息弹出/讨论内选择选项(cog图标)
- 选择删除会话...,并在确认提示中说出删除对话
- 再次选择留言
- 选择开始使用
- Open Facebook in a desktop browser and go to the page linked to your messenger bot
- Press "Message"
- Inside the message popup/discussion choose "Options" (cog icon)
- Select "Delete Conversation..." and say "Delete Conversation" in the confirmation prompt
- Select "Message" again
- Select "Get Started"
步骤4.真正删除您在页面/应用程序中拥有的聊天记录小心点。
Step 4. really deletes the chat history you are having with the page/app so beware.
这篇关于Facebook Chat Bot - 如何测试欢迎讯息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文