node.js - How to display a greet message include text and image in nodejs -
i want show greeting message when user start conversation on facebook messenger before user input message.
i did code in node js server triggers when user sends message want show greeting message below.
i want know should code welcome message. read https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text here text possible.
this link text greeting facebook messenger :how show greeting message when start conversation
if using nodejs, use request (or curl) create greeting button , pass parameter listen on 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 response });
after that, can listen post called 'get_start' , return 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 messenger bot", "image_url": "https://mybot.example.com/images/logo.jpg" } } } } } }, (err, res, body) => { // deal response });
Comments
Post a Comment