This is a basic server application that consumes audio from Twilio Media Streams.
It's a good starting point to develop your own application logic.
Requires Node >= v12.1.0
Run npm install
npm dependencies (contained in the package.json):
- httpdispatcher
- websocket
Start with node ./server.js
You can setup your environment to run the demo by using the CLI (BETA) or the Console.
-
Find available phone number
twilio api:core:available-phone-numbers:local:list --country-code="US" --voice-enabled --properties="phoneNumber" -
Purchase the phone number (where
+123456789is a number you found)twilio api:core:incoming-phone-numbers:create --phone-number="+123456789" -
Start ngrok
ngrok http 8080 -
Edit the
templates/streamsfile to replace<ngrok url>with your ngrok host. -
Make the call where
+123456789is the Twilio number you bought and+198765432is your phone number andabcdef.ngrok.iois your ngrok host.twilio api:core:calls:create --from="+123456789" --to="+198765432" --url="https://abcdef.ngrok.io/twiml"
- Access the Twilio console to get a
<TWILIO-PHONE-NUMBER>. - Run the server (listening on port 8080)
- Use ngrok to make your server publicly available:
ngrok http 8080 - Edit the streams.xml file in the
templatesdirectory and add your ngrok URL aswss://<ngrok url> - Run the curl command in order to make the proper call
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/<ACCOUNT-SID>/Calls.json -d "Url=http://<ngrok url>/twiml" -d "To=<PHONE-NUMBER>" -d "From=<TWILIO-PHONE-NUMBER>" -u <ACCOUNT-SID>:<AUTH-TOKEN>