'Place a Twilio call on hold and retrieve it later
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?
Solution 1:[1]
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:
- Provide Twilio some TwiML that places the call into "hold" then
- 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.
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Devin Rader |
| Solution 2 | Max |
