Facebook Chat Bot - How do I test the welcome message?

Lee Woodman picture Lee Woodman · Apr 20, 2016 · Viewed 8.3k times · Source

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?

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

exampleofissue

Answer

otso picture otso · Apr 20, 2016

Try this:

  1. Open Facebook in a desktop browser and go to the page linked to your messenger bot
  2. Press "Message"
  3. Inside the message popup/discussion choose "Options" (cog icon)
  4. Select "Delete Conversation..." and say "Delete Conversation" in the confirmation prompt
  5. Select "Message" again
  6. Select "Get Started"

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