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

Add FaceBook parametric codes #790

Merged
merged 2 commits into from
Apr 26, 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
12 changes: 12 additions & 0 deletions docs/readme-facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ bot.reply(message, reply_message)

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.

- Get Static Codes :
```javascript
controller.api.messenger_profile.get_messenger_code(2000, function (err, url) {
if(err) {
Expand All @@ -314,6 +315,17 @@ controller.api.messenger_profile.get_messenger_code(2000, function (err, url) {
});
```

- Get Parametric Codes :
```javascript
controller.api.messenger_profile.get_messenger_code(2000, function (err, url) {
if(err) {
// Error
} else {
// url
}
}, 'billboard-ad');
```

## Thread Settings API

Thread settings API is now messenger profile API, it's highly recommended to use profile API instead of thread settings one, however, Botkit thread settings interface still available :
Expand Down
7 changes: 6 additions & 1 deletion lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,16 @@ function Facebookbot(configuration) {
}
});
},
get_messenger_code: function(image_size, cb) {
get_messenger_code: function(image_size, cb, ref) {
var message = {
'type': 'standard',
'image_size': image_size || 1000
};

if(ref) {
message.data = {'ref': ref};
}

request.post('https://graph.facebook.com/v2.6/me/messenger_codes?access_token=' + configuration.access_token,
{form: message},
function(err, res, body) {
Expand Down