Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Add Messenger code API #689

Merged
merged 2 commits into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,40 @@ function Facebookbot(configuration) {
}
});
}
},
get_messenger_code: function(image_size, cb) {
var message = {
'type': 'standard',
'image_size': image_size || 1000
};
request.post('https://graph.facebook.com/v2.6/me/messenger_codes?access_token=' + configuration.access_token,
{form: message},
function(err, res, body) {
if (err) {
facebook_botkit.log('Could not configure get messenger code');
cb(err);
} else {

var results = null;
try {
results = JSON.parse(body);
} catch (err) {
facebook_botkit.log('ERROR in messenger code API call: Could not parse JSON', err, body);
cb(err);
}

if (results) {
if (results.error) {
facebook_botkit.log('ERROR in messenger code API call: ', results.error.message);
cb(results.error);
} else {
var uri = results.uri;
facebook_botkit.log('Successfully got messenger code', uri);
cb(null, uri);
}
}
}
});
}
};

Expand Down
15 changes: 15 additions & 0 deletions readme-facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,21 @@ reply_message = {
bot.reply(message, reply_message)
```


## Messenger code API

Messenger Codes can be scanned in Messenger to instantly link the user to your bot, no typing needed. They're great for sticking on fliers, ads, or anywhere in the real world where you want people to try your bot.

```javascript
controller.api.get_messenger_code(2000, function (err, uri) {
if(err) {
// Error
} else {
// uri
}
});
```

## Thread Settings API

Facebook offers a "Thread Settings" API to customize special bot features
Expand Down