Twilio Gather, take user's input without delays - twilio

I am using gather verb to take user's input, but I play mp3 before user press a key.
The problem is I would like to post a user's input to action URL before mp3 file is finished to play.
My TwiML doesn't take any user's inputs until the mp3 file is finished to play.
I am not sure if there is a way to just post user's input right away when user press a key.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Play>http://www.action.com/greeting.mp3?1925924752</Play>
<Play>http://www.action.com/selection.mp3?1925924752</Play>
<Gather NumDigits="1" Timeout="5" Method="GET" Action="Http://www.action.com/handler.Php?Repeated=1"/>
<Redirect Method="GET">http://www.action.com/handler.php?repeated=1</Redirect>
</Response>
Thank you.

Twilio evangelist here.
Just drop those <Play> verbs into your <Gather>:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Play>http://www.action.com/greeting.mp3?1925924752</Play>
<Gather NumDigits="1" Timeout="5" Method="GET" Action="Http://www.action.com/handler.Php?Repeated=1">
<Play>http://www.action.com/selection.mp3?1925924752</Play>
</Gather>
<Redirect Method="GET">http://www.action.com/handler.php?repeated=1</Redirect>
</Response>
Hope that helps.

Related

Twilio recordingStatusCallback is never called

Trying to receive recordings of calls. I'm self hosting this twiml code.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial timeout="40"
recordingStatusCallbackEvent="in-progress,completed"
recordingStatusCallback="http://server.com/recording/">
<Number
url="http://server.com/whisper/"
statusCallbackEvent="completed"
statusCallback="http://server.com/status/">
+12142142144
</Number>
</Dial>
</Response>
Everything works as expected except the recording url is never called. The call forwards, the whisper is spoken, the status url is called, but not the recording url.
Twilio Developer Evangelist here. 👋
It looks like you're missing the record attribute. (https://www.twilio.com/docs/voice/twiml/dial#record) If it's not set it's defaulting to do-not-record.
<Response>
<Dial record="record-from-ringing-dual"
recordingStatusCallback="www.myexample.com">
<Number>+15558675310</Number>
</Dial>
</Response>
Can you add it and give it a try? Happy to help if that's not the issue. :)

Can I insert a variable into TwiML? In particular, to insert the phone number of the number called?

Is there a way to implement the following in TwiML? The goal is to produce a reasonably-sounding voicemail on Twilio.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="15"/>
<Say voice ="woman">
You have reached the voice mail of ##The_Phone_Number_One_has_Called##.
Please leave a message at the beep.
</Say>
<Record
transcribe="true"
/>
</Response>
I have a bunch of Twilio numbers and would like to have the string "##The_Phone_Number_One_has_Called##" replaced by the number that the caller is calling. Please advice if I should deploy a dedicated TwiML for each phone number.
Using Templates with a TwiML Bin, and Polly voices, try something like this for the bin:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="15"/>
<Say voice="Polly.Joanna">
You have reached the voice mail of
<say-as interpret-as="telephone">{{To}}</say-as>.
Please leave a message at the beep.
</Say>
<Record
transcribe="true"
/>
</Response>
How to use templates with TwiML Bins
(https://support.twilio.com/hc/en-us/articles/230878368-How-to-use-templates-with-TwiML-Bins)
Amazon Polly
(https://www.twilio.com/docs/voice/twiml/say/text-speech#amazon-polly)
You could do it on your server's code. Just replace the "##The_Phone_Number_One_has_Called##" with the phone that the user called.
Remember that you get the number that the user dialed on the post param "To" on each of Twilio's requests to your server, so from your server you could return:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="15"/>
<Say voice ="woman">
You have reached the voice mail of $POST["To"].
Please leave a message at the beep.
</Say>
<Record
transcribe="true"
/>
</Response>
And your server will render a different phone each time, and Twilio's will say it. Just a heads up, the $POST["To"] has the format "+1XXXXXXXXXX", so you might want to remove the +1.

Setup whisper for callee - So when I answer, I know where the call is coming from

I am sorry. I am a new to this so forgive me in advance. I'm searching for an answer and I was not able to understand when searching previous inquiries.
I am starting a TwiML Bin and so far my code is
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>This call is being recorded for quality assurance purposes</Say> .
<Dial record="true">+1 858-220-8650</Dial>
</Response>
When I receive the forwarded phone call, and I answer it, I want a message to say "phone call from website xyz" and then connect the call.
Is this possible from just within the TwiML Bin? Or do I have to utilize some external code?
You can do it with TwiML Bins, you will need to use the URL attribute on the Number noun to "chain" them together.
First create your whisper bin:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>phone call from website xyz</Say>
</Response>
Then use this with the URL attribute on your existing bin, like this:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>This call is being recorded for quality assurance purposes</Say>
<Dial record="true">
<Number url="https://handler.twilio.com/twiml/xxxxxxxxxxxxxxxxxxxxxxx">
18582208650
</Number>
</Dial>
</Response>
When the call is answered it will say the message from the whisper bin immediately before connecting the calls. Hope this helps! :)

Is there a way with twilio to stop the welcoming message (Say) on the caller digit inputs and then forward it to the next IVR tree

Is there a way with twilio to stop the welcoming message (Say) once the caller input digits and then forward it to the next IVR tree without waiting the whole message ?
Thanks
You can use numDigits attribute in GATHER with a integer value.For example, one might set 'numDigits' to '5' and ask the caller to enter a 5 digit zip code. When the caller enters the fifth digit of '94117', Twilio will immediately submit the data to the 'action' URL.
Check detail on Twilio Docs.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather timeout="10" numDigits="5">
<Say>Please enter your pin number and then press star.</Say>
</Gather>
</Response>
Actually I had the Gather after the Say. Instead I should've wraped the Gather around the say:
<Response>
<Say voice="alice" language="it-IT">...</Say>
<Gather method="POST" numDigits="1" action="/twilio/ServletHandleUserInput" finishOnKey="0">
</Gather>
</Response>
So I amended it alike :
<Response>
<Gather method="POST" numDigits="1" action="/twilio/ServletHandleUserInput" finishOnKey="0">
<Say voice="alice" language="it-IT">...</Say>
</Gather></Response>
Thanks Rubai

How to Add Custom Parameters when Recording Twilio Call?

How would you recommend associating a Twilio call recording with the call?
Is there a parameter that shows which call the recording applies to? Here is the documentation: https://www.twilio.com/docs/api/twiml/record
Or is there a way to pass a custom parameter from my app such as "event_id" when setting up the recording below?
<Dial hangupOnStar="true">
<Conference record="record-from-start" eventCallbackUrl="/twilio/receive_recording_url">custom_conference_id from my app</Conference>
</Dial>
Twilio will pass the recording URL with its request to the "action" url
<?xml version="1.0" encoding="UTF-8"?>
<!-- page located at http://example.com/voicemail_record.xml -->
<Response>
<Say>
Please leave a message at the beep.
Press the star key when finished.
</Say>
<Record
action="http://foo.edu/handleRecording.php"
method="GET"
maxLength="20"
finishOnKey="*"
/>
<Say>I did not receive a recording</Say>
</Response>
http://foo.edu/handleRecording.php will receive via GET:
RecordingUrl: the URL of the recorded audio
RecordingDuration: the duration of the recorded audio (in seconds)

Resources