This is a quick guide to get you started with using Twilio text-to-voice in a workflow.
In this tutorial, you will:
Learn how to format TwiML
Use cURL to test your text-to-voice
Create a workflow to call a number using text-to-voice
Here’s what you need to get started:
HTTP permissions from M1
Twilio Account SID (find here twilio.com/console)
Twilio Auth Token (find here twilio.com/console)
From number (registered with your Twilio account)
For more info, check this out: https://www.twilio.com/docs/voice/make-calls#post-parameters
TwiML
TwiML is Twilio’s XML that you use to tell Twilio what to say in the call and how to say it.
To learn more about TwiML, go here https://www.twilio.com/docs/voice/twiml
As a reference, this is the TwiML used in the demo:
<Response>
<Pause length="1"/>
<Say voice="Polly.Joanna">There is a problem with your pump. The level is currently at 0.4.</Say>
</Response>
cURL
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/<account SID>/Calls.json" -u "<account SID>:<auth token>" -d "To=<number, ie: +14087970103>" -d "From=<number, ie: +14087970103>" -d 'Twiml=<Response><Pause length="1"/><Say voice="Polly.Joanna">There is a problem with your pump. The level is currently at 0.4.</Say></Response>' -d "MachineDetection=DetectMessageEnd"
Workflow
import HTTP # need M1 permissions to use this library
# this info can be found on your Twilio console
account_sid = "<account SID>"
auth_token = "<auth token>"
url = "https://api.twilio.com/2010-04-01/Accounts/" + account_sid + "/Calls.json"
to_num = "<number, ie.+14087970103>"
from_num = "<number, ie.+14087970103>" # must be registered with your Twilio account
twiml ='<Response><Pause length="1"/><Say voice="Polly.Joanna">There is a problem with your pump. The level is currently at 0.4.</Say></Response>'
params = "To=" + to_num + "&From=" + from_num + "&Twiml=" + twiml + "&MachineDetection=DetectMessageEnd"
r = HTTP.post(url, params, username=account_sid, password=auth_token, headers={"Content-Type": "application/x-www-form-urlencoded"})
log(r)