5

I am creating a Twilio application using JavaScript SDK.

I want to implement call hold functionality but I am having trouble implementing it.

What is the process to put a call on hold, when it is initiated by the soft-phone? Also, what is the process when the soft-phone is receiving the call?

Nisarg Shah
  • 14,151
  • 6
  • 34
  • 55
ashishcloud
  • 267
  • 3
  • 16

3 Answers3

9

Twilio evangelist here.

There are different ways to place a call on "hold". Normally it does not matter whether the call originated from Client or from a PSTN number, the process is generally the same:

  1. Provide Twilio some TwiML that places the call into "hold" then
  2. when you are ready, use that calls CallSid and the REST API to redirect the live call to a new experience.

Now, for placing the call on "hold" there are a couple of options I can suggest:

One is to use the <Play> verb and set the loop attribute to zero, which will tell Twilio to loop over that audio indefinitely. When you are ready to move the call out from "hold", you simply redirect the call.

Another option is to use the <Enqueue> verb and place the call into a call queue. Then when you are ready simply redirect that call back out of the queue to a new experience.

Hope that helps.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32
  • Hello Devin, I am trying to do same thing, put call on hold and then retrieve again, but instead of putting end user on hold it just disconnect and play music on my side, why this is happening? – Manish Goyal Aug 26 '15 at 17:57
  • @ManishGoyal Can you post some code in a new SO question. Hard to tell what might be happening otherwise. – Devin Rader Aug 26 '15 at 20:25
  • yes, here it is http://stackoverflow.com/questions/32233250/how-to-put-twilio-call-on-hold – Manish Goyal Aug 27 '15 at 04:45
  • not working for me. What i am doing is when I receive a call. On button press ajax would be called and on server side i am using this code `use Twilio\TwiML\VoiceResponse; $response = new VoiceResponse(); $response->enqueue('support', ['waitUrl' => 'http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3']);` – Haisam Hameed May 07 '19 at 09:33
  • This is a few years old- Studio has come along, as well as conference...wondering if this question could get updated with current information - here or perhaps a blog post???? – codeputer Dec 10 '19 at 12:35
3

When the user of the soft phone press Hold you can use the REST API to update that call, sending the call to a queue.

You can do that redirecting the call to a TML file with the <Enqueue> tag.

To retrieve the call to the soft phone you can use the CallSid to update the call and sending it back to the soft phone user.

I already implemented that feature in my app, so let me know if you need some help.

Megan Speir
  • 3,745
  • 1
  • 15
  • 25
Maxi Capodacqua
  • 303
  • 1
  • 15
  • Hello Maxi , I am trying to do same thing, put call on hold and then retrieve again, but instead of putting end user on hold it just disconnect and play music on my side, why this is happening? – Manish Goyal Aug 26 '15 at 17:57
  • 1
    @ManishGoyal , probably you are using the wrong CallSid, make sure that you are using the CallSid of `theirs` call and not `ours` call – Maxi Capodacqua Aug 27 '15 at 17:32
  • Can't I put call receiver on hold if I have initiated a call? – Manish Goyal Aug 27 '15 at 18:07
  • Yes you can, but when you put the call on hold you have to make sure that the `CallSid` is the one that you want to put on hold. For every call leg you'll get a `CallSid`, one for every "connection" (your app and the other phone). For example, if I make an outgoing call, that call will relates 2 `CallSid`s, one for my app, and the other for the called number, you have to use the `CallSid` of the called number instead of yours. Makes sense? I had that problem in the past and to chose the right `CallSid` depends on the implementation of your calls. – Maxi Capodacqua Aug 31 '15 at 01:18
  • @MaxiCapodacqua trying to do exactly this at the moment, and struggling a bit with the end part of update the call and sending it back to the soft phone user.', how does one achieve that? I can Enqueue the call fine, but not clear how to get it back to the original agent that put the call on hold – OJay Sep 18 '17 at 05:41
  • there is parentCallSid. you have to use that sid – Yashraj basan Jun 05 '20 at 10:27
0

Adding more to the answer,

If you connected two calls with,

[call1] <enqueue>queue_id</enqueue>

and

[call2] <dial><queue>queue_id</queue></dial>

add some pause to any of the call. Like,

<dial><queue>queue_id</queue></dial><Pause length="10"/>

This way when you need to put a call on hold by updating the call via <Enqueue> it will not disconnect instantly. You need to first update call1 by putting it to <enqueue> and then updating the second call to some long wait music.

when you need to unhold the call, you can just <dial><queue> again.

Max
  • 1,528
  • 21
  • 33