DEV Community

Cover image for Alexa skill with Twilio voice Integration
Tejasvi Shinde
Tejasvi Shinde

Posted on

Alexa skill with Twilio voice Integration

Imagine you give a command to your Amazon Echo/Alexa to make a phone call🤙🏻

Pre-requisites

  • Twilio
  • Knowledge of Alexa Custom Skills
  • AWS Lambda

One such technology is Amazon Alexa, it provides the programming blocks to implement voice-based interactions with a customer through the Amazon Echo speaker. While Twilio provides the voice communication layer between the customer and your backend contact center infrastructure.

1) What is Twilio

Twilio is a developer platform for communications. Software teams use Twilio APIs to add capabilities like voice, video, and messaging to their applications. This enables businesses to provide the right communications experience for their customers.

Requirements

  • Twilio account
  • Twilio AccountSid and Auth Token
  • Twilio Number

Reference links

Twilio sign-up
Twilio voice API

You need to create a Twilio account. once you have one, you can get a free phone number for your country. Make sure the phone number you get at Twilio supports voice.
In your Twilio account settings, you need to find out the account session Id and authentication token. You will need them in the next stage when creating your Lambda function.

TwilML
TwiML (the Twilio Markup Language) is a set of instructions you can use to tell Twilio what to do when you receive an incoming call, SMS, or fax.
How TwiML works
When someone makes a call to one of your Twilio numbers, Twilio looks up the URL associated with that phone number and sends it a request. Twilio then reads the TwiML instructions hosted at that URL to determine what to do, whether it's recording the call, playing a message for the caller, or prompting the caller to press digits on their keypad.
At its core, TwiML is an XML document with special tags defined by Twilio to help you build your Programmable Voice application.

to learn more refer here

2) Alexa custom skill kit

you just need to follow few steps to create a custom skill follow this

3) Aws lambda

1.If you don't already have one, get an Amazon AWS account (free).
2.From the AWS Console (https://aws.amazon.com), you need to create a Lambda function which will execute the code that will send the request to Twilio voice outbound call.

Creating a lambda function steps

1.Create a new Execution Role for the function by selecting Create New Role->Basic Execution Role. In IAM console, create new IAM Role, enter name and clock Allow button.
2.Go to AWS Services and select Lambda
3.Click Lambda and follow the process for adding Name. Choose the Node.js as the Runtime, Role and create the function. The Lambda function that we have created is shown in the screenshot below
Alt Text
4.Select 'Event Sources' tab and add Alexa Skill Kit event source
5.Now, save the Lambda function.

If you stuck in between please check this

It helped me because I am also not completely familiar with AWS so any suggestions or help much appreciated.

also in the lambda function
Create the payload we want to send, including the Twiml location, from which Twilio will fetch instructions when the call connects

Alt Text

I hope you found this post helpful.

Top comments (0)