I have a soft phone system set up and all is good. A call comes in to my soft phone, and I can put it on hold, transfer the call, etc. by clicking a button and sending a request to Twilio's REST API, or my server, or whatever it may be.
My question is, is it possible to update an in progress call if I am called on my SIP hard phone? What I want to do is, for example, during an in-progress call enter *1 to put the call on hold. Because it's a hard phone, I can't simply hit a button to make a request to my server.
I know I can use Gather to accept my input, but if I am on an in-progress call, how would I even initiate the Gather?
Sorry this isn’t written all that well, doing on my phone.
It would be tough, as you need the callsid to initiate redirect. However, if you store your calls in Sync Lists, you could make a Function and have it either look up the phone number of the call and return the callsid to use in the redirect or enter the unique ID for the entry on the list.
Tie that function to a phone number, call via a your desk phone, put an if(event.digits) {obtain callsid from sync, then redirect, then callback() } else {do a gather() and don’t worry about the action url as you’ll just go to the top of this function but now you’ll have event.digits, then do your callback} do not do a callback here or you’ll skip all of your above code}
Related
I am working with Twilio Voice JS SDK. Every incoming calls are converted to conferences. I can do this.
If there is a second incoming call, I want a user can answer it.
But if I invoke call.accept(), the first call will disconnect.
So I tried to hold the first call by update ParticipantResource.Update() with hold = true. This doesn't help. I listen hold music from browser and the first call is still active.
Is it possible to answer the 2nd incoming call/conference?
We have a use case where we need the device client, connected within the browser, to be able to trigger different Say verbs at any given time during the live call between the device client and the caller. Whatever is said needs to be heard for both client and caller and included in the recording.
I set up an API endpoint that takes the CallSid and updates twiml, however, the statement is only heard for the device client and the calls are immediately disconnected. From my understanding, this is intended due to how TwiML works, since there is no other command after Say, so it believes the call is complete.
return await client.calls(callId)
.update({ twiml: '<Response><Say>Ahoy there!</Say></Response>' });
I've considered using a Redirect which would put the caller into a new flow to hear the prompt, however, the device client then wouldn't hear it, and it wouldn't be part of the recording, so that will not work. Using a conference call, the statement is only played for the new call either before they join or after their call ends.
Is there any way to accomplish this?
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.
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.
I am trying to figure out a way to capture if the caller hangs up in the middle of TwiML instructions. If the caller hangs up (abandons the call) does twilio notify the application of such?
I see the status callback url setting but I just get a "completed" status. I was wondering if the caller was in a middle of a gather and hung up would twilio know the call hung up and report it? Or am I supposed to just see the "completed" status and at that time determine if the call actually successfully completed or not?
Twilio evangelist here.
To my knowledge we don't have a specific way of telling you that a caller hung up during the middle of a <Gather> other than the status callback passing you the CallStatus, which as you points out just tells you that the call was completed, not where within a TwiML document or a call flow the caller was.
If you want to know where within a call flow the call ends (for example the caller hangs up), I'm pretty sure that is something you would need to track in your own application. You could do that by storing the callSid of the phone call along with some meta data that helps your app know where in the flow the call is, and just updating each time Twilio makes a webhook request to your app.
Hope that helps.