I am writing an application in which we would like to receive an incoming call and stream it.
To achieve this we have configured the following twiml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Start>
<Stream url='wss://<URL>/api/twilio/audio/stream' />
</Start>
<Say language='en-US'>Hello</Say>
<Gather method='Get' action='http://<URL>/api/twilio/incoming/response' input='speech'/>
</Response>
The idea is to start the streaming as soon as the call is connected, and then make the call continue using gather. The gather action would respond back with another gather. The call will be disconnected once the necessary actions are done.
What we are observing is that the stream starts, but the call gets disconnected post that and the gather action is never called.
Would appreciate if someone can point out what I am doing wrong and how to resolve the issue.
Finally figured out what the issue was, with some help from Twilio support
In this case the request was being sent to http:///api/twilio/incoming/response
The response from the /incoming/response API was a Twmil, but the content type was text/plain;charset=UTF-8
This made Twilio just play out the string.
Modified it to text/xml and that fixed the issue.
Related
I'm trying to simulate a typical phone behaviour, where a call comes in and "rings" until someone picks it up, however I'd like to problematically control this pickup action.
Initially, when the call comes in, I throw the following TwiML at the call:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="300"/>
<Reject reason="busy"/>
</Response>
This delays answering the call by up to 5 minutes while the app waits for user input. The caller hears ringing during this time. If there's no input within 5 minutes, the app will disconnect the call as busy. Once the user or program has decided what to do with the call, I'd like to be able to send a new TwiML instructions.
However, when I use the method described here to modify the call, I am given an error by Twilio that the call can't be modified as it's not in-progress.
Is there any way to send new instructions towards the call at this point to have it answered and redirected during the Pause?
You cannot modify the call until you answer it (in-progress), as the error message suggests. You must wait for the <Pause length="300"/> to complete, as it is the first verb in the returned TwiML and the call will remained unanswered until it completes and a TwiML Verb which answers the call is reached.
TwiML™ Voice: Pause
I am building an Interactive Voice Assistant using Twilio. My goal is to record parts of the conversation, process the recorded audio and
This is the answer to the /voice webhook (the one will receive Twilio's call)
<Response>
<Play>./welcome</Play>
<Record maxLength="10" action="/processing" recordingStatusCallback="/getRecording"></Record>
</Response>
Processing the audio and providing an answer may take a long time, so I added a Pause at the end of /processing:
<Response>
<Play>./ok</Play>
<Pause length="10"></Pause>
</Response>
This is the answer when finished with /getRecording
<Response>
<Play>./answer</Play>
<Record maxLength="10" action="/processing" recordingStatusCallback="/getRecording "></Record>
</Response>
/welcome, /ok and /answer lead to corresponding audio files.
So I was able to execute all steps, I can check in my logs that /getRecording is actually executed to the end and the twiml sent back again, but the /answer after /getRecording is never executed by Twilio (and the call just ends).
Do you have any guidance for it? Does Twilio accept multiple recordings on the same call?
Note: For some reason, if instead of using the 'recordingStatusCallback' I use /getrecording as 'action' it does work... but then we wouldn't be sure the recording we are using is really generated, right?
Thank you for your help!
Twilio developer evangelist here.
Your /getRecording endpoint is called, however that is an asynchronous webhook in the context of the call. Returning TwiML to the recordingStatusCallback will not affect the current call.
Instead, you should use the REST API to modify the call by redirecting it to the next TwiML you want to execute based on the response to the recording file.
Hopefully the recording does take less than the 10 second pause that you are using, but you may want to add a loop into your /processing endpoint so that the call won't hang up on your caller. You can do this by redirecting the caller back to the start again:
<Response>
<Play>./ok</Play>
<Pause length="10"></Pause>
<Redirect>./processing</Redirect>
</Response>
Then, when you get the recording callback you redirect your caller out of this loop.
Let me know if that helps at all.
For my Twilio number I have TwiML App and I am using Flask as a backend to handle URL for incoming calls. My goal is to create behavior that for every incoming call it hangs up (and send sms, but this is not so relevant at the moment)
so far I used:
Twiml Response with Hangup ends with "busy signal"
Twiml Response with Reject ends with message "number you are calling is not available"
using twilio rest client (like in Twilio's example) client.calls.update("CAe1644a7eed5088b159577c5802d8be38", status="completed") also results in "busy signal"
twilio rest client: client.calls.hangup(twilio_call_sid) also results in "busy signal"
so I am running out of ideas and I can't believe that it's not possible to finished incoming call (without answering) clearly with no busy signal, or I am probably missing something.
I would appreciate any help
Realize this is coming way late, but if you want to simply respond to incoming calls with an SMS you can use the <Sms> TwiML verb to do so.
And then from the users perspective, gracefully end the call with <Hangup>.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Sms from="+14105551234" to="+14105556789" action="URL_TO-HANGUP_TWIML">Say hello StackOverflow.</Sms>
</Response>
Question
Implementing voicemail in Twilio. How can I get a call back if the caller hangs up before the recording starts?
More info
After the incoming call's <dial> times out, the call back URL responds with this:
<Response>
<Say>Please leave a message.</Say>
<Record playBeep="true" action="http://..." />
</Response>
The issue I seem to be having is that if the caller hangs up while the <Say> verb is executing, the <Record> verb never executes and thus the application never receives a call back.
Is it possible to receive a call back under this circumstance? If so, how do I make that happen?
Twilio evangelist here.
One idea might be to separate this TwiML response into two separate responses and track what the last step in your workflow you sent to the call was. First send the Say:
<Response>
<Say>Please leave a message.</Say>
<Redirect>http://example.com/record</Redirect>
</Response>
Then redirect to the Record:
<Response>
<Record playBeep="true" action="http://..." />
</Response>
To get notified when the call ends, set the StatusCallback attribute on your phone number. When Twilio makes the request to the StatusCallback URL, you can check to see what the last step that you sent to the user was and take the appropriate action.
Hope that helps.
When a Twilio number receives an incoming voice call, what TwiML can I use so that the phone continues ringing indefinitely?
In certain circumstances, I want to pretend that the phone is ringing but there's nobody around to answer it and there's no voicemail configured. I thought the Reject verb could help. It appears to support only a busy signal or a "number disconnected" message.
One can use the Pause verb to have Twilio delay pickup. By specifying a sufficiently long delay, the call effectively rings "forever". For example,
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Pause length="600"/>
<Hangup />
</Response>
Probably the easiest way to do this is going to be to get an mp3 recording of a ringing phone, one that is very long (you can find them by googling) and setup twilio to <Play> the mp3 when someone calls it - I've done it and its very convincing.
Doing this will give you the extra benefit of letting you track who calls that number and how long they let it ring (of course you get billed for this).