I have a twilio number that can process incoming calls with twiml. These incoming calls expect the recipient to press some digits after the call is connected.
If I were making an outgoing call, I could use the sendDigits attribute of a <Dial> tag. However, I can't figure out how to do this in response to an incoming call.
If I were receiving the call in a web client, I could use connection.sendDigits
Is there a way to do this in just twiml? Should I just play a recording file of various DTMF tones?
Edit: To clarify, I'm receiving calls from another automated system that expects additional numbers to be dialed after the call is connected.
Turns out the way to to do this is by using the <Play> twiml tag, which accepts a digits attribute.
<Play digits="94"></Play>
Related
I have a number which I have configured to use a TwiML App. In the App itself, I have set the VoiceURL and StatusCallback on the Voice section.
The issue is, the callback is triggered when there is an incoming call to the Twilio-bought number.
However, if I place an outgoing call from the Twilio-bought number, the callback is not triggered.
Is this the expected behaviour, that the TwiML app callback is only triggered on incoming calls?
If this is not the intended behaviour, any pointers on what may be going wrong?
That is expected, that statusCallback URL handles only the incoming call leg.
If you are forwarding that call(which creates another call leg), you can use the parameter of the name name of the Number noun to capture events.
If you are using the REST API to make an outbound call, it has a statusCallback parameter as well.
I would like to initiate an outgoing call from twilio to a number provided by a service like nexmo and be able to listen to the response.
Based on the voice message back from the receiver, i would like to determine my response
I have gone through the documentation, and from what i can make out, the outgoing call does not give me an access to the incoming stream. The Call object allows me to control the call, but not based on the voice response
client.calls
.create({
url: 'http://demo.twilio.com/docs/voice.xml',
to: '+15558675310',
from: '+15017122661'
})
.then(call => console.log(call.sid));
The call object does not provide me a way to access the conversation audio.
Overall, I would like the call to be initiated and my caller program to get access to the response voice messages that it can parse and then determine the next response.
Should i consider SIP for this scenario, since the destination number will also be having a SIP endpoint?
I was able to achieve this with the standard Twiml
The Gather verb of twilio will wait to receive voice packet and then perform speech recognition on it and send back the text.
In response to this callback, i am sending back the next audio to play and immediately followed by the next Gather.
Suppose for an incoming call to a Twilio Number '+18XXXXXXXXXX' the call is forwarded to a client with name 'CLIENT'. Now there are two legs with Callsids 'CSid1' and 'CSid2'.
If the 'CLIENT' wants to hold the call, the Connection leg with Callsid 'CSid1' is redirected to a Music url. If the 'CLIENT' resumes the call, the call 'CSid1' is again redirected to the 'CLIENT' with new CallSid 'CSid3'.
Now, how to get the single recording url for the whole Incoming call (connection with CallSid 'CSid1').
Note: The recording url for connection with callsid 'CSid2' and 'CSid3' can be obtained by setting record verb in dial tag (Two recording urls).
Any other suggestions to achieve Incoming Call recording in Twilio with hold option is also welcome.
Twilio developer evangelist here.
If you want to record the whole call in one recording, including holds, then you may want to investigate using a <Conference>.
Once your original caller dials in, put them into a <Conference>, using <Dial> with the record attribute set. At the same time, use the REST API to make a phone call to the client which also lands them in the conference.
You can then use the Participants resource to hold and unhold the caller.
This would not redirect the caller, therefore giving you one recording URL.
Let me know if this helps.
For Outbound Calls From An App to a Number,
There are two legs - One between my browser and Twilio and the other between Twilio and the number to be dialled
Can I set a webhook to trigger, on each callstatus value change (especially when the Call Status is in-progress) of the second leg and How?
This is necessary so that I can start the timer and show hold button only after the customer picks up the phone
Any other idea to achieve this also Welcome. Thanks in advance.
Twilio developer evangelist here.
When you dial out from Twilio Client you can send parameters into the request, such as the number, then Twilio will send your application a webhook with those parameters to find out what to do next. To dial a number, you would use the <Dial> verb and nest a <Number> within it.
With a <Number> you can register for webhook callbacks when certain events take place. You do so by setting a statusCallback attribute to the URL that will receive the callback. By default the statusCallback URL will only receive the completed event when the call finishes, however you can register for more events using the statusCallbackEvent attribute.
The event you want to subscribe too is called "answered" and the TwiML you need is:
<Response>
<Dial>
<Number statusCallback="http://example.com/calls/callback" statusCallbackEvent="answered">
NUMBER TO DIAL
</Number>
</Dial>
</Response>
Let me know if that helps at all.
I am using twilio's call screening / whisper example. So basically when we use the Dial verb to call the number, we want to play a message when the receiver picks up the phone and give them the option to accept/reject the call. While the caller should keep hearing the ringing tone until the receiver makes a choice.
Most of this works as expected if we follow what's described in the call screening example https://www.twilio.com/docs/howto/callscreening
The problem is as soon as the receiver picks the phone, the caller can no longer hear the ringing tone, and the call goes silence until we have a response back from the receiver. This is a huge problem, because the caller will probably hang up once the ringing tone stops and there is no answer.
I have already had a look at the following two answers.
Twillio Call Screening silence on answer
Detecting when call had been answered using Dial verb
I personally don't want to go down the conference route.
In Number verb's documentation its clearly mentioned that the caller will continue to hear ringing tone.
https://www.twilio.com/docs/api/twiml/number#attributes-url
The 'url' attribute allows you to specify a url for a TwiML document that will run on the called party's end, after she answers, but before the parties are connected. You can use this TwiML to privately play or say information to the called party, or provide a chance to decline the phone call using Gather and Hangup. The current caller will continue to hear ringing while the TwiML document executes on the other end. TwiML documents executed in this manner are not allowed to contain the Dial verb.
The same issue happens with the Find Me Twimlet as well.
twilio.com/labs/twimlets/findme
Contacted Twilio support, you'll need to set "ringTone" attribute on like this:
<Dial answerOnBridge="true" ringTone="us">
I have tried that and it worked for me.