Twilio: Dial out from conference - twilio

I have an incoming phone call that is waiting in a conference. While they are waiting, our application looks for an appropriate rep based on some business logic to connect to them too. If we are unable to find a rep, we would like to forward the call to a general number. It's possible that this number will dial to voicemail.
Normally, I would dial out, and when the phone is picked up I would connect the call to the conference. The issue with that workflow is the person in the conference will not hear the call being dialed out, and it also presents challenges with voicemails (I need the inbound call to know if they are leaving a voicemail).
How can I either remove the inbound caller from the conference and dial out to the generic number, or call out from the conference?

I found from here: https://twilio.radicalskills.com/projects/conference-calling-voice/3.html (under "modify live calls") that using the original call Sid you should be able to remove them and send new twiml instructions. Whoopie!
edit: I was asked to expand on my answer. Here is what I'm doing:
The caller is already waiting in a conference, I need to "remove" them and dial out.
Using the Rest API I send a Redirect to the original call sid of the call that was put into a conference.
The Redirect url returns a twiml dial app to the number I want the original call to be connected to.
That's it :)

Related

twilio python outbound dial

I am trying to use my laptop (running Twilio) to dial a land line using python 3 and have have a voice conversation. This is the simplest use case.
Here is the python code I am running on my laptop.
def test_voice_command_inline(self):
'''calls landline from laptop via twilio'''
twilio_client = twilio.rest.Client(self.twilio_account_sid,
self.twilio_auth_token)
vps_url = self.get_vps_url()
twilio_voice_call = twilio_client.calls.create(
from_=self.twilio_phone_number,
to=self.land_line_number,
url=vps_url
)
When I run this code, my land line rings, and I answer it. The call is connected. Next I get prompted by Twilio to press a key to "execute my code" (aka the webhook)
Since I already have a connected call, I don't need a webhook. I just want to start talking. However, the Twilio rest api requires me to put in a webhook url that returns TwiML to direct the call flow. And when the TwiML is finished processing, the call is hung up. I don't need a webhook, yet I am required to have one.
I tried various things in the webhook code in an attempt to let the already connected call continue. I tried returning blank TwiML from my webhook, which causes an immediate hangup. I also tried dialing the land line number from inside the webhook. Since the rest api already connected the call, trying to re-dial the number from the webhook caused a busy status (Twilio console). Looking at all the TwiML verbs I can use in the webhook, none look appropriate for my needs.
I must be missing something simple. Why can't I use the code above to make a voice call between my laptop and my land line (or any other phone)?
Twilio developer evangelist here.
When you make an outbound call using the REST API, Twilio is setting up a call between our server and the to number. The from number that you supply is just the callerId for the call.
In order to connect the call you make with the REST API to another phone, you need to return TwiML from your twiml_url that dials another number. Currently your TwiML is just an empty <Response> but it should be something like this:
<Response>
<Dial><Number>OTHER_NUMBER</Number></Dial>
</Response>
This can be written out by Python code too, if you want it to be dynamic. That's where you use the VoiceResponse that you mention. The important thing is that the second leg of the call that you are making should be controlled by TwiML returned from your URL.
Let me know if that helps at all.

Twilio Mobile to Mobile Call

I am new to Twilio and I need some help on a specific scenario. I have been trying to find a solution for this for some time, but I haven't been able to do so.
I want to use a Twilio number from one mobile (A) to call another user on mobile (B). I want to do this in a manner where the call is initiated by the Twilio number and not by (A)'s phone number.
In other words, (A) dials a Twilio number from a mobile and Twilio in turn dials (B) and connects (B) with (A).
I have configured the Twilio phone number dialed by (A) to used a Twiml bin and I have used the Dial verb to dial (B) upon receiving the call from (A).
But the Dial verb adds user (B) to the call. USer (B) does not see the call coming from the Twilio number but from User (A). This is not what I was hoping to achieve.
First of all, I hope I have been able to explain the scenario properly.
IS the scenario possible?
IS it possible for me to get Twilio to dial another user's number when it receives a call from a user? (without using the dial verb in Twiml).
IS there any solution in the API?
Let me know your thoughts. Also, please feel free to ask for any clarifications
Yes it's possible, you just need to supply a callerId parameter in your TwiML. Without one then Twilio will just use the incoming callers number as the caller ID, as you are currently experiencing.
You can use any Twilio number you have purchased or any number you have verified as the displayed caller ID. Your TwiML dial verb should look like this:
<Dial callerId="+15551231234">
<Number>+1555555555</Number>
</Dial>

Transferring a call in Twilio while playing hold music for the caller

I'm building a system where the callers need to be connected to an external system that has its own IVR tree. I need the caller to hear hold music, while we are dialing and sending DTMF digits to the external system.
I got it to work by dialing into the external system using REST API, and putting both calls (incoming and outgoing) into the same conference room. However, this prevents me from sending the caller's caller ID to the external system like the <dial><number></dial> command does. Unfortunately this is a hard requirement.
Any suggestion on how I can accomplish this?
Edit:
I ended up using <dial> verb to dial into the external system, and transfer the call into a conference room using REST API right after the outgoing call is connected.
You can store callers calling information in a variable, and then use callerId parameter in Dial.
https://www.twilio.com/docs/api/twiml/dial#attributes-caller-id
I ended up using <dial> verb to dial into the external system, and transfer the call into a conference room using REST API right after the outgoing call is connected.

Connecting phone calls with twilio

This is more of a general quest ok but when using Twilio dial in a twiML to connect the caller to another number, can you disconnect Twilio after they are connected or will it just keep connected and increase the call time?
Twilio developer evangelist here.
It sounds like you are asking whether, when you direct a phone call to a TwiML app with something like this:
<Response>
<Dial><Number>OTHER_PHONE_NUMBER</Dial>
</Response>
that you want to disconnect from Twilio once the call is connected to the number?
If that's the case, then the answer is no, I'm afraid. Once a call comes into Twilio, it is being controlled and routed by the Twilio system and you will incur costs by the minute. Whilst this call continues to live you will still be able to affect it via the REST API using its call SID.
Let me know if this helps or if you have any other questions.

How to change caller id during call in twilio

I have 2 phone numbers registered as caller ids in my twilio account.
Is is possible to change the caller id during call. Lets say i am using Phone 1 as a caller id but during call if user presses 1 he will be connected to other user. But Before connecting to other user i want that Phone 2 works as caller id.
Is it possible? Please help
Twilio evangelist here.
Based on your description of the workflow, I believe this is possible.
I assume you are using <Gather> to listen for Caller1 to indicate he wants to be connected to another call. If thats the case, in the URL thats requested once Caller1 had pressed one, you're going to return some TwiML that includes the <Dial> verb to tell Twilio to dial Caller2 and bridge them with Caller1. The <Dial> verb has a callerID attribute that you can set to one of your verified caller ID's, and that is what will be shown to Caller2 when Twilio rings them.
https://www.twilio.com/docs/voice/twiml/dial#dial-attributes
Hope that helps.

Resources