Serverless Boilerplate - Twilio - Node.js - Forward a call
Twilio is a commincations API provide that allows developers to build applications using phone calls, SMS, emails and more. To configure communications a lot of services work with a configuration language called TwiML.
This example projects helps you deploy a serverless function to the Twilio runtime. The function responds the TwiML configuration to forward phone call.
Make sure serverless
is installed globally. See installation guide.
You will also need to set up your Twilio account credentials using environment variables. You find these in your Twilio Console.
Needed environment variables are:
TWILIO_ACCOUNT_SID
TWILIO_AUTH_TOKEN
MY_PHONE_NUMBER
1. Install Twilio Node.js Provider Plugin & Service Dependencies
npm install
in this directory to download the modules from package.json
.
2. Deploy
serverless deploy
or sls deploy
. sls
is shorthand for the Serverless CLI command
3. Invoke deployed function
serverless invoke --function forward-call
or serverless invoke -f forward-call
-f
is shorthand for --function
In your terminal window you should see the response from Apache OpenWhisk
<?xml version="1.0" encoding="UTF-8"?><Response><Dial>+491...</Dial></Response>
Congrats you have just deployed and run your Forward Call function!
For more information on the Twilio Runtime Serverless plugin, please see the project repository: github.com/twilio-labs/serverless-framework-integration.