Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 628
Lee Woodman Avatar asked Apr 20 '16 14:04

Lee Woodman


People also ask

How do you test a Facebook bot?

Select the Messenger channel connected to the Facebook page you want to test the chatbot with. Or, if you haven't yet, create a Messenger channel following this guide. Once you are into the Messenger channel, go to Linked bot and select the chatbot you want to test from the dropdown.

How do I change the automated welcome message on Facebook?

Click Settings from the menu on the left of your Page. Click Messaging in the left column. Next to Show a greeting, click to select On. Click Change, edit the greeting, then click Save.

What is welcome message in chatbot?

The welcome message is the first interaction between the chatbot and the user. It can either encourage the user to start a chat or discourage them from further conversation.


3 Answers

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.

like image 112
otso Avatar answered Oct 04 '22 13:10

otso


  • On desktop, delete the conversation and message the page again.

This will allow you to see the "Get Started" button again, allowing you to test it and your welcome message's functionality.

If you're trying to test the "Messenger Greeting", it's a lot more complicated. See below.


On Desktop the "Messenger Greeting" still will not show up after deleting the conversation. Only the "get started" button reappears. I believe this is a bug that I will be opening up a ticket for most likely.

You can get a similar experience on mobile by deleting the conversation, uninstalling, and reinstalling Messenger, but once again that does not display the Messenger greeting, it only shows the get started button.

Not being able to see the Messenger Greeting again is an issue for developers who are picky about the line-by-line formatting of the Messenger greeting, or who simply need to see it again for a demo of the messenger bot once the greeting has already been seen.

Thankfully, although EXTREMELY painful, there's a workaround. Basically have to re-setup your bot.

  1. Create a new page
  2. NEVER OPEN A MESSAGE WITH THE PAGE/BOT UNTIL STEP 17
  3. Click settings, Messenger, and set your messenger greeting, and press save.
  4. Since that doesn't actually save the toggled setting for some reason, select a different thing from messenger in the sidebar
  5. Reselect Messenger
  6. Turn on the greeting (the message should have saved properly, just not the toggle for whether its on or off)
  7. Change to a different thing in sidebar
  8. Re-select Messenger and double check that the messenger greeting is enabled
  9. Create a new app
  10. Add Messenger as a product
  11. Select the page and copy the page access token
  12. Put the page access token where it is needed in your code
  13. Run your code
  14. Connect to the webhook url with your verify token and all the boxes checked
  15. After webhook connection is successful, subscribe it to your new page
  16. Run your curl command to enable the 'get started' button and your welcome message that will happen after the button is pressed
  17. Open a message with your page, and the Messenger greeting and get started button should appear. YOU GET ONE CHANCE AND THEN YOU'LL HAVE TO REPEAT ALL OF THESE STEPS TO SEE THE GREETING AGAIN.

I believe the toggle on messenger greeting not saving right is also a bug, and I may open a ticket for it.

like image 40
user2322082 Avatar answered Oct 04 '22 12:10

user2322082


There is a way to get the welcome screen in Messenger on iOS (at least as of Apr 28th), although it's super annoying. Basically, in addition to deleting the convo, you have to reinstall the app on your phone.

  1. Go to the paged linked to your bot in facebook on desktop
  2. Archive the conversation
  3. Open Messenger on your phone and delete the conversion by swiping right on the cell in the conversation list
  4. Delete Messenger from your phone
  5. Reinstall Messenger from the App Store
like image 25
Stas Nikiforov Avatar answered Oct 04 '22 11:10

Stas Nikiforov