How do I have Twilio make a silent call that only sends digits, not voice via mp3/wav?

495 views Asked by At

I'm writing a small program to check my voicemail and email the recording to me at set intervals. Here's the python code for the call portion, at least up to testing basic call & AUDIX option tree navigation once the call connects:

from twilio.rest import TwilioRestClient

# put your own credentials here
ACCOUNT_SID = ""
AUTH_TOKEN = ""

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
ext = ""
ext_passwd = ""
digs = "wwwwww#ww" + ext + "wwww" + ext_passwd + "#wwwwww2"


call = client.calls.create(
        to="+",
        from_="+",
        url="",
        send_digits=digs,
        record="true"
)

print call.sid

The url parameter is required, and it seems the target has to be TwiML containing a reference to an audio file that will play when the call connects. I want a silent call, at least from that end, and just to send the digits necessary to navigate my voice mail.

I assume I'm missing something? Or do I really need to host a TwiML file, and reference an "empty" mp3 with a second or two of silence in it?

1

There are 1 answers

1
beanserver On BEST ANSWER

Try removing the send_digits and record parameters, instead use a url which describes a similar flow in TwiML.

In the XML returned at url, you can use the digits attribute of the <Play> tag to send dialpad digits and the <Record> tag to capture the subsequent audio on call. You could even transcribe the voicemails to text this way.

Here's an example of what the TwiML at url might look like:

<?xml version="1.0" encoding="UTF-8"?> <Response> <Play digits="wwwwww#ww1234wwww4321#wwwwww2"></Play> <Record timeout="10" transcribe="true" transcribeCallback="/handle_transcribe" /> </Response>