Answer the second incoming call/conference - twilio

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?

Related

How to receive multiple incoming calls in same browser device at the same time?

Currently we are getting incoming call in Twilio Javascript client device using the code below
Device.on('incoming', function(incomingCall) {
console.log(incomingCall)
incomingCall.accept();
});
We need to receive a second incoming call in the same device simultaneously, after answering the first call ( That is, when the first call is in progress )
We are able to receive the second call only if the first one is in ringing state, We have to find a solution to receive the second call while the first one is in progress
Thanks
In the Device options you need to set allowIncomingWhileBusy to true. Then when the Device receives an incoming call while there is already an active call, it will fire the incoming event.
Check out more detail in the Device Options documentation.

Update an in-progress Twilio call from a hard phone

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}

Stop / Start call recording on Twilio

Is there an API that I can use to stop recording an ongoing call?
We have a feature here where you can record only pieces of a call. So you can click a button to stop recording, and then after some time you can click another button to start recording again.
How can I accomplish that on Twilio? I didn't find anything in their docs.
Twilio developer evangelist here.
There's no direct way to start and stop recording a call, however you could manage this using <Gather> and <Conference>.
The idea would be that callers would join a conference (even if there's just two of them) which recorded their call using the record attribute.
You would wrap that <Conference> in a <Gather> that was waiting for a caller to dial a particular digit which stops recording by redirecting the caller who pressed the digit to a new <Conference> without the record attribute set.
You will also need to redirect the other call to that conference too. When you get the webhook after the first caller pressed a digit to stop recording you can fire off a REST API call to redirect the second caller to the new non-recorded conference.
If you wrap this second <Conference> in a <Gather> too, you can reverse this process to start recording again.
Let me know if that helps at all.
[edit]
As a further consideration, I realised that you indicated you need a user to press a button to start or stop recording. I initially thought of this as a button on your phone, which is why I suggested using <Gather>. If, however, the user in control of recording is an agent in a call centre, for example, you could build an easier interface using Twilio Client to make or receive the calls.
Then, when the calls are connected into the initial conference you'd need to record both the Call SIDs.
You could then implement a button in your interface that when pressed transfers both calls from a recording conference to a non recording conference (or vice versa). Again, this would use the REST API to redirect the calls.

Twilio start call forwarding after the prior call is disabled

I have a use case where I want to forward a call from A to C. Here if the call is already forwarded to some number i.e A to B, then I need to disable the current forwarding(i.e A to B) and then enable the new call forwarding(i.e A to C). But the new forwarding should start only if the disable call worked. I am using twilio webhook call to identify the call status. The approach I have followed is, in the method to which webhook sends response, I am checking the status of call. So when its completed, I try to find the Phone A from my apps database using call_Sid. I am storing call_Sid against the phone number that is to be forwarded. But here is the main problem.
Now when I receive status as completed for disabling I need the number to which I need to forward the call to. How should I get this new number to be passed into this method which handled twilio webhook response.
Please let me know how to achieve this.
hey this issue look like previous one on Twilio call forwarding
someone facing issue with twilio call forwarding and got its solution:
It is not possible to forward calls to a Twilio number and have that number call you back if you've set up call forwarding on your phone.

Use Record and Dial together in Twilio API

I am using Twilio to create call tracking phone numbers that redirect to another number using the Dial verb. I am also recording these calls. Here is an example of my TWIML
<Response><Dial record="true" action="http://example.com/PostCall">555-555-5555</Dial></Response>
I want to be able to terminate the call recording but not the call using something like the Record verb's finishOnKey option. Is this possible?
The reason is, a call comes in to a call center and is transferred to a lawyer. I want to record the call center part of the call but not the attorney/client part of the call. If pressing # during the call could stop the recording but keep the call active it would solve my problem.
Is there a way to stop recording without terminating the call?
Can the record verb be used in conjunction with the dial verb?
The <Record> TwiML verb is best if you want to record one person talking. I'm assuming you want to record both parties connected via <Dial> in the call center so you would rely on the record attribute as you have above.
Read the FAQ for the full breakdown on the difference in recording settings.
Is there a way to stop recording without terminating the call?
Depending on the flow of your call center you might modify the live call via the REST API and redirect the call to new TwiML where you set recording to "false".
call = client.calls.update("CALL_SID", url="https://example.com/no-record.xml",
method="POST")
Alternatively, you could add Twilio itself as a 3rd call leg in a <Conference> call, and let it handle recording. This way you can use the REST API to modify that leg without disrupting the primary 2 callers, including stopping recording of the call midway through while the other 2 callers are still live.

Resources