forked from twilio-labs/call-gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinbound-call.js
30 lines (24 loc) · 827 Bytes
/
inbound-call.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
require('dotenv').config();
// You can use this function to make a
// test call to your application by running
// npm inbound
async function makeInboundCall() {
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
let twiml = new VoiceResponse();
twiml.pause({ length: 10 });
twiml.say('Which models of airpods do you have available right now?');
twiml.pause({ length: 30 });
twiml.hangup();
console.log(twiml.toString());
await client.calls
.create({
twiml: twiml.toString(),
to: process.env.APP_NUMBER,
from: process.env.FROM_NUMBER
})
.then(call => console.log(call.sid));
}
makeInboundCall();