messenger-bot-tutorial icon indicating copy to clipboard operation
messenger-bot-tutorial copied to clipboard

how to setup a greeting message when start conversation.

Open dromerobarria opened this issue 8 years ago • 3 comments

I would like to know how to show greeting message when start conversation, without waiting for the user message.

dromerobarria avatar Aug 23 '16 03:08 dromerobarria

There is a separate API to do this. Refer to, Thread Settings

maheshambiga avatar Sep 12 '16 06:09 maheshambiga

Please help me more because the tutorial uses commands and i didn't get the actual effect of the command. For example when i run this command curl -X POST -H "Content-Type: application/json" -d '{ "account_linking_url": "ACCOUN_LINKING_URL", "persistent_menu": { PERSISTENT_MENU_SETTINGS }, "target_audience": { TARGET_AUDIENCE_SETTINGS } }' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=PAGE_ACCESS_TOKEN"

i got this message {"result":"success"} but i didn't get the actual effect in my bot. So please help me, I am a beginner at building bots :D

FehrHassan avatar Mar 07 '17 23:03 FehrHassan

Please see the sample code written for NodeJS below,

import express from 'express'; var app = express();

app.post('/webhook', function (req, res) { threadSettingsAPI(); }

function threadSettingsAPI(){ var messageData = { "setting_type":"call_to_actions", "thread_state":"new_thread", "call_to_actions":[ { "payload":JSON.stringify({ action:"GET_STARTED", params:{} }) } ] };

request({
    url: 'https://graph.facebook.com/v2.8/me/thread_settings',
    qs: {access_token:process.env.PAGE_ACCESS_TOKEN},
    method: 'POST',
    json: messageData
}, function(error, response, body) {
    if (error) {
    } else if (response.body.error) {
        console.log('Error: ', response.body.error)
    }
})

}

maheshambiga avatar Apr 07 '17 07:04 maheshambiga