Managed Connection: Twilio
Last updated
Last updated
Twilio allows us to send and receive text messages globally using applications like VoiceWorx platform.
The VoiceWorx platform allows for the rapid integration of Twilio Text message service to various voice channels such as, Alexa, Lex, Google Assistant and more.
You need to have an active Twilio account
Enough balance so you can send messages.
Configuration
Account SID
Auth Token
Phone Number
Twilio uses two credentials to determine which project an API request is coming from: The Account SID, which acts as a username, and the Auth Token which acts as a password.
To get the required information, Log into your Twilio Account. If you do not already have a Twilio account, click on Sign Up for free and fill the details as shown below to get a trial account.
You’ll get a confirmation message on your mail, confirm the account and you shall be directed to the Twilio dashboard
Save the following details from the Twilio dashboard:
Account SID
Auth Token
The next step is to get a trial number from Twilio so that we can proceed our tests with Twilio SMS and MMS. By default, the trial account has a trial balance which can be used to get the trial numbers.
Click on Get a Trial Number, you’ll be provided an option, select on Choose this number and you’ll receive the confirmation message as shown below:
To manage the Phone numbers, click on Phone numbers menu in the left navigation and select options to manage active numbers, released numbers, buying a new number etc.
If you do not have any Active Number, you can purchase one by clicking on “Buy a Number” option available in the same screen in left menu.
Keep record of your Account SID, Auth Token and Twilio phone number. Go to Connect System on Integration Menu. Click on Add New Connection.
Select following:
Integration Category: Custom
System Type: Twilio
Fill in the details from above steps and click on Validate and Save Settings.
You can now use the integration to build apps in VoiceWorx that can use Twilio to send SMS and MMS.
On Manage Apps menu under Custom Apps menu in the left navigation, click on New Custom App.
Fill up following details to create app.
Name: Twilio Demo
Custom App Type: Search
Category: Default
Click on Save.
Next step is to create a datasource that communicates with the integration created in Step 2.
After the data source has been created, we now have to create methods. VoiceWorx supports
SendTextSMS
SendSMSWithMedia
Fill the following details:
You can now test the method. On the actions menu, click on Test, provide the parameter value and
Fill the following details:
You can repeat the same method to test the method. Following screen shows a sample response.
Create Intents corresponding to the methods.
SendTextSMSIntent
SendSMSWithMediaIntent
Slots represent the parameters for the intents. You shall create slots of the exact same name as the parameters used in the method. Slots map to the parameters of the method.
SendTextSMSIntent
SendSMSWithMediaIntent
Utterances are the short texts that invoke the intent. You have to define a unique utterance for each method.
SendTextSMS
SendSMSWithMedia
The next step is to create input for the intents. Create Inputs corresponding to every intent. You need to create and manage parameters corresponding to the slots for each intent. For example for SendTextSMSIntent, you had two slots: “ToNumber” and “Message”, hence for SendTextSMSInput , you need to create two parameters: “ToNumber” and “Message”. Let’s look into the process in the following screens:
SendTextSMSInput
Click on Manage parameters on the action menu.
Click on Input Parameters and provide the details as shown below in the resulting pop up: Make sure to map the Input parameter to the same parameter. Also be careful of the data type used. It should be similar/ compatible with the data type of the slot.
Let’s Add another parameter “Message”.
Send SMSWithMediaInput
Repeat the same process for SMSWithMediaIntent. Create Input “SMSWithMediaInput” and create parameters.
Parameter Details:
Once you’ve completed all of the above steps, your app is now ready to be publish to VoiceWorx supported channels. Let’s set up a publish profile.
Click on Save and you shall see the publish profile in VoiceWorx portal. Click on the actions menu and then on Publish to Alexa.
Select the appropriate LWA account and click on publish.
On success, you shall get a similar screen
Click on Go to Alexa Skill. It will redirect you to Alexa developer console, where you can start testing your app starting with the skill invocation text defined in previous step.
For further details on app building, you can refer to this document for required guidance on building the remaining steps of app building.
Click on Method Test . You can observe the return from method in Object tab and the result displayed to user in Result Tab.