Skip to content

Instantly share code, notes, and snippets.

@andreas-optimizely
Created September 27, 2017 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreas-optimizely/9cdcde9aee37f023507dcabf42b91b64 to your computer and use it in GitHub Desktop.
Save andreas-optimizely/9cdcde9aee37f023507dcabf42b91b64 to your computer and use it in GitHub Desktop.
// Sending a Messenger template message
function sendGenericMessage(sender, data) {
messageData = data;
request({
url: 'https://graph.facebook.com/v2.6/me/messages',
qs: {access_token:token},
method: 'POST',
json: {
recipient: {id:sender},
message: messageData,
}
}, function(error, response, body) {
if (error) {
console.log('Error sending messages: ', error)
} else if (response.body.error) {
console.log('Error: ', response.body.error)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment