Search code examples
node.jsfacebookmessenger

Unable to set greeting text for Messenger bots


I'm trying to set a greeting text for one of my Messenger bot like this:

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"call_to_actions",
  "thread_state":"new_thread",
  "call_to_actions":[
    {
      "payload":"Greeting"
    }
  ]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"

As well as like this:

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"greeting",
  "greeting":{
    "text":"Timeless apparel for the masses."
  }
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"

Also, the same is set from my page's messaging settings

messaging settings

Messenger correctly shows the Get Started button:

Messenger correctly shows the Get Started button

But nothing like greeting comes on the bot

nothing like greeting comes on the bot

What could be the problem apart from page access token


Solution

  • I don't know what you need exactly. However, let me guess that you want to something which once someone clicks the Get Started button, then the messenger bot send the user like "Welcome to the Bot! I wanna help you with xxx", right?

    First, you need to set the Get Started button postback.

    curl -X POST -H "Content-Type: application/json" -d '{
      "get_started": {"payload": "<postback_payload>"}
    }' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>"
    

    Besides talking to the server using curl, you need to handle The Get Started Button Postback with writing the code in your file app.js.

    switch (payload) {
        case 'get_started':
            sendGetStarted(senderID);
            break;
    
        default:
            sendTextMessage(senderID, "Postback called");
    }
    

    For further more information, please check the documentation on https://messenger.fb.com/developers/tutorials/setting-up-the-welcome-screen/