messenger-bot-tutorial
messenger-bot-tutorial copied to clipboard
how to setup a greeting message when start conversation.
I would like to know how to show greeting message when start conversation, without waiting for the user message.
There is a separate API to do this. Refer to, Thread Settings
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
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)
}
})
}