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

3

6

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

Superscribe answered 20/4, 2016 at 14:23 Comment(2)
Can you point me to somewhere I can i find how to do this in php?Thank youMaurinemaurise
@Maurinemaurise gist.github.com/visitdigital/58c71acb123870d1ac2ec714d7536587Superscribe
G
17

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.

Galaxy answered 20/4, 2016 at 20:39 Comment(6)
Correct...although...there is a weird messages in the Facebook Messenger API docs. "The Welcome Screen only appears for new conversations. Deleting conversations will not cause the Welcome Screen to appear." See that here: developers.facebook.com/docs/messenger-platform/…Superscribe
I think there is a bug in iOS messenger as that Get Started button only appears on Desktop and not Mobile.Superscribe
Also, is there any way to set up the welcome screen? Mine only has a "Get Started" button.Feverwort
That's what users need to do to initially engage with the botSuperscribe
Looks like they've edited the docs and cleared the confusion. Now the documentation says: "The Welcome Screen only appears for new conversations. On mobile, deleting conversations will not cause the Welcome Screen to appear again. On desktop web, if you delete the conversation, you can make the Welcome Screen appear again." developers.facebook.com/docs/messenger-platform/…Stickler
I figured out why this solution wasnt working for me! You need to use the messenger on facebook.com NOT the one on messenger.com if you delete the convo there you still don't get the welcome message just get started button.Shiite
S
4
  • 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.

Stygian answered 23/6, 2016 at 16:0 Comment(3)
I have upvoted this just because this is still a bug.Fuchsin
@Stygian I see that they (FB team) mention they have fixed this. However, I still face the same issue (as a developer). Do you still find the same bug?Apfel
Late reply, but if it's on desktop, it's probably a new unrelated bug. When I was working with this, the bug was fixed a couple days before that bug report was closed. Never had problems since, but I also haven't worked with it in a while after ironing things out when they fixed it.Stygian
U
2

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
Unaccountedfor answered 28/4, 2016 at 16:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.