Skip to content

Instantly share code, notes, and snippets.

@jesuscast
Created August 28, 2016 21:39
Show Gist options
  • Save jesuscast/a49af02d1d6ed2d3521b0c265e5665df to your computer and use it in GitHub Desktop.
Save jesuscast/a49af02d1d6ed2d3521b0c265e5665df to your computer and use it in GitHub Desktop.
function sendTextMessage(sender, text) {
let messageData = { text:text }
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