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

Send broadcast function: added missing args(notification and tag) #1280

Merged
merged 2 commits into from
Mar 15, 2018
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
16 changes: 16 additions & 0 deletions docs/readme-facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,22 @@ controller.api.broadcast.send('<CREATIVE_ID>', null, function (err, body) {
});
```

If you would like to add notification type and tag you can pass an object:

```javascript
var message = {
message_creative_id: '<CREATIVE_ID>',
notification_type: '<REGULAR | SILENT_PUSH | NO_PUSH>',
tag: '<MESSAGE_TAG>'
}

controller.api.broadcast.send(message, null, function (err, body) {
// Your awesome code here
console.log(body['broadcast_id']);
// And here
});
```

### Broadcast Metrics

Once a broadcast has been delivered, you can find out the total number of people it reached by calling ```controller.api.broadcast.get_broadcast_metrics(...)```.
Expand Down
13 changes: 9 additions & 4 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,21 @@ function Facebookbot(configuration) {
}
});
},
send: function(message_creative_id, custom_label_id, cb) {
send: function(message_creative, custom_label_id, cb) {
var uri = 'https://' + api_host + '/' + api_version + '/me/broadcast_messages?access_token=' + configuration.access_token;
var body = {};

if (facebook_botkit.config.require_appsecret_proof) {
uri += '&appsecret_proof=' + appsecret_proof;
}

var body = {
'message_creative_id': message_creative_id
};
if (typeof message_creative === 'string') {
body = {
'message_creative_id': message_creative
};
} else {
body = message_creative;
}

if (custom_label_id) {
body.custom_label_id = custom_label_id;
Expand Down
Loading