-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpass_thread.js
More file actions
33 lines (31 loc) · 778 Bytes
/
pass_thread.js
File metadata and controls
33 lines (31 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Function to pass thread control
const rp = require('request-promise');
module.exports = async (sender_psid) => {
appID = 263902037430900;
token = process.env.PAGE_ACCESS_TOKEN;
// Construct the message body
var request_body;
var state;
// Create a request Body.
request_body = {
"recipient": {
"id": sender_psid
},
"target_app_id":appID
}
// Try the request after setting up the request_body.
try{
var options = {
method: 'POST',
uri: `https://graph.facebook.com/v7.0/me/pass_thread_control?access_token=${token}`,
body: request_body,
json: true
};
state = await rp(options);
console.log(`User: ${sender_psid} moved to page inbox.`);
}
catch (e){
console.log(e.message)
}
return state;
}