-
Notifications
You must be signed in to change notification settings - Fork 0
/
addMessages.js
34 lines (31 loc) · 903 Bytes
/
addMessages.js
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
34
const { auth } = require('strapi-provider-upload-do/lib');
exports.handler = function(context, event, callback) {
var auth = 'Bearer ' + context.EXT_API_TOK1 + context.EXT_API_TOK2;
var got = require('got');
got(context.BASE_URI + '/messages', {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": auth
},
json: {
"data": {
"FromNumber": event.From,
"ToNumber": event.To,
"Body": event.Body,
"MessageId": event.MessageSid,
"Direction": event.Direction,
"caller": event.Caller,
"CampaignId": event.CampaignId
}
},
})
.then(function(response) {
console.log(response.body)
callback(null, response.body);
})
.catch(function(error) {
console.log(error)
callback(error);
});
}