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

Add FB Thread owner API #1353

Merged
merged 2 commits into from
Jul 9, 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
11 changes: 11 additions & 0 deletions docs/readme-facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,17 @@ controller.api.handover.request_thread_control('<RECIPIENT_PSID>', 'String to pa
});
```

### Get Thread Owner

Th Thread Owner API returns the app ID of the app the currently has thread control for a Page :

- To get the app ID of the current thread owner :
```javascript
controller.api.handover.get_thread_owner('<RECIPIENT_PSID>', function (result) {

});
```


## Messaging type

Expand Down
36 changes: 36 additions & 0 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,42 @@ function Facebookbot(configuration) {
}
}
});
},
get_thread_owner: function(recipient, cb) {

var uri = 'https://' + api_host + '/' + api_version + '/me/thread_owner';

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

request.get({
url: uri,
qs: {
recipient: recipient,
access_token: configuration.access_token
},
json: true
}, function(err, res, body) {
if (err) {
facebook_botkit.log('Could not get thread owner');
if (cb) {
cb(err);
}
} else {
if (body.error) {
facebook_botkit.log('ERROR while getting thread owner : ', body.error.message);
if (cb) {
cb(body.error);
}
} else {
facebook_botkit.debug('Successfully getting thread owner', body);
if (cb) {
cb(null, body);
}
}
}
});
}
};
var broadcast_api = {
Expand Down