Specifying Twilio Incoming and Outgoing Callbacks using TwiML App - twilio

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.

Related

Setting statusCallbackEvent on outbound calls with Voice SDK

Is there any way to change what events trigger the status callback? Normally you can use statusCallbackEvent but I can't seem to find a way to make this work for the Voice SDK's leg of the call. It works fine on the call leg of the outbound participant, but not the Voice SDK's call leg. I only get completed status event for this leg (and I also can get ringing from the called action url).
Things I tried without success:
Updating the call using the REST api to set statusCallbackEvent to initiated ringing answered completed when the outbound call starts
Setting statusCallbackEvent as an outbound parameter on the Voice SDK's token (in PHP you can set custom parameters using $clientToken->allowClientOutgoing(...) but it seems normal parameters cannot be modified)
I really wish you could set this on the TwiML Application so that any numbers calling out with that application set will just automatically use your set events. That or let me set the parameters on the client's token.
One way to fix this is just to poll for the information but that is an ugly hack and isn't real time.
Twilio developer evangelist here.
I don't think you can do what you're asking for here, but for good reason.
When you are placing the call from the Voice SDK, that call leg is then between the application and Twilio. You know the call was "initiated", because you started it. There is no "ringing" because Twilio is not a phone and won't ring. You know it is "answered" because a request is made to your voice URL defined by the TwiML app. And finally, you do get the "completed" event.
As you say, you do get the events for the outbound leg of the call from Twilio to another phone number.

Twilio - determine if a number is already in a call before initiating

I have a somewhat peculiar situation for which I can't find documentation: I have an application that will use the Twilio API to initiate a voice call from phone number X (my number) to another one. The problem is that number X could already be in the middle of another call, one that was not initiated with Twilio (so my application wouldn't know about it). Would Twilio detect this, and send an error, or try to initiate the call anyway? If the former, what would the error be? I have found the error code for "callee busy", but nothing similar to "caller busy".
Alternatively, is there an API call I could make before initiating the call to make sure number X is available and not in another call?
Twilio numbers can have multiple calls associated with them, so there would be no error id the Phone X was on an existing call (since phone numbers can be routed however you choose). You can set the outbound CallerID to be another Twilio number or a verified callerID (but if they call that verified callerID back, it wont go back to Twilio but the carrier/business owning that number).
Once the dialed party answers after making the outbound API call, you tell Twilio how to route the other piece (who to connect the answering party to) via the URL parameter hosting the Twilio Markup Language (TwiML).
There is an API call and example for, Read multiple Call resources and filter by call status and phone number (Code Example), you could query before making your outbound call (assuming you always map inbound calls to the same endpoint) or routing your inbound call (which probably makes more sense if you want to re-route to another destination who can answer the call).
The status of this call. Can be: queued, ringing, in-progress, canceled, completed, failed, busy or no-answer.

Call Forwarding and Callee ID

I would like to forward call from mobile phone numbers to a single Twilio number (using regular carrier forwarding functionnality).
I would like to know if there is any way to get the original callee id from the incoming call on the Twilio number (i.e. the mobile number of the original recipient of the forwarded call).
Said differently, I would like to be able, when I receive the call on Twilio, to make the difference between calls forwarded from the number A and calls forwarded from number B.
If this is not possible like this, is there any other option ?
My recommendation would be to not forward the calls to Twilio and call the Twilio number directly. The ability to capture the original called number is carrier dependent and not reliable.
ForwardedFrom - https://www.twilio.com/docs/voice/twiml#request-parameters
You could also forward the call to Twilio via SIP (rather then over the Public Switched Telephone Network), and possibly pass an X-Header with the original Caller ID, but that is most likely not possible with your existing carrier.

Can I send digits to an incoming twilio call with twiml?

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>

Parameter pass in linphone ios outgoing call

I want to send parameter in outgoing call. Then I will get the parameters in incoming call for another user. How and where it's possible to make.

Resources