-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo.js
46 lines (38 loc) · 1.23 KB
/
demo.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
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
const flowroute = require('./lib');
console.log('Flowroute Demo');
// Set up your api credentials and test mobile number for outbound SMS or MMS
flowroute.Configuration.username = 'YOUR_API_KEY';
flowroute.Configuration.password = 'YOUR_API_SECRET';
// Instantiate API client and create controllers for Numbers
const numbersController = flowroute.NumbersController;
numbersController.listAvailableAreaCodes().then((areaCodes) => {
console.log('First 10 Available Area Codes');
console.log(areaCodes);
},
(error) => {
console.log(error);
});
const mobile_number = YOURNUMBER;
const number_id = YOURNUMBER;
const messagesController = flowroute.MessagesController;
request_body = {
"data": {
"type": "message",
"attributes": {
"to": String(mobile_number),
"from": String(number_id),
"body": "hello there",
"is_mms": "true",
"media_urls": ["http://s3.amazonaws.com/barkpost-assets/50+GIFs/37.gif"]
}
}
}
console.log("request", request_body)
result = messagesController.createSendAMessage(request_body).then((result) => {
console.log("Message result")
console.log(result)
},
(error) => {
console.log("Message Error", error)
})