0

I want to show greeting message when user start a conversation on Facebook messenger before user input any message.

I did code in node js server that only triggers when user sends a message but I want to show greeting message like below.

enter image description here

I want to know where I should code for welcome message. I read this https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text but here only text is possible.

This link also for text greeting Facebook Messenger :How to show a greeting message when start conversation

Community
  • 1
  • 1
N Sharma
  • 33,489
  • 95
  • 256
  • 444
  • Have you checked the documentation for "Get Started" [1]? You should probably configure your chat thread to display such a button, and listen for the callback from the Get Started button. Then send your card (with image) upon the webhook call is received. [1] https://developers.facebook.com/docs/messenger-platform/thread-settings/get-started-button – AndreasB Jul 06 '16 at 11:45
  • Thanks @AndrewB I am not getting "Get Started", I have enabled it in settings of page settings & followed all steps of here http://stackoverflow.com/a/36754730/1741671 . Could you please help ? – N Sharma Jul 06 '16 at 12:03
  • Hm, @Williams. I didn't change anything in the settings to include the Get Started button, I simply send the data structure they propose on the previous link I sent under "Examples". – AndreasB Jul 07 '16 at 05:23

2 Answers2

0

If you are using nodejs, use request (or curl) to create the Greeting button and pass a parameter to listen on the post back.

let request = require('request');

request.post({
    method: 'POST',
    uri: `https://graph.facebook.com/v2.6/me/thread_settings?access_token=${ACCESS_TOKEN}`,
    qs: {
        setting_type: 'call_to_actions',
        thread_state: 'new_thread',
            call_to_actions: [{
                payload: 'GET_START'
            }]
        },
    json: true
}, (err, res, body) => {
    // Deal with the response
});

After that, you can listen for a post back called 'GET_START' and return a welcome message.

request({
    method: 'POST',
    uri: 'https://graph.facebook.com/v2.6/me/messages',
    qs: {
        access_token: ACCESS_TOKEN
    },
    json: {
        recipient: {
            id: SENDER_ID
        },
        message: {
            attachment: {
                type: "template",
                payload: {
                    template_type: "generic",
                    elements: {
                        "title": "Your Title",
                        "subtitle": "Welcome to my messenger bot",
                        "image_url": "https://mybot.example.com/images/logo.jpg"
                    }
                }
            }
        }
    }
}, (err, res, body) => {
    // Deal with the response
});
Rafael
  • 1,295
  • 14
  • 21
0

You currently can't send text and an image in the same message as far as I'm aware.

The closest you can get to what you want is to use the generic template. The only issue is that you would need to make use of a button.

Bcf Ant
  • 1,639
  • 1
  • 16
  • 26