Outgoing Dial Into Conference From Customer's Number - php

I am trying to have all my incoming calls automatically go to conference. This part can be achieved using:
<Response>
<Dial>
<Conference>Room <?php echo($_REQUEST['From']);?></Conference>
</Dial>
</Response>
This way, each caller goes into their own separate conference room. The part I can't figure out how to do is the outbound call from that point. I need to make a SIP call to my PBX using the customer's caller id so an agent can answer it. When they answer, they should be sent to the same conference room.
I found this for making outbound calls into a conference. However, I want the outbound call to the agent to use the caller id of the customer. This way, the agent can see the customer's phone number.
The main reason I want to use a conference and not a direct dial is because I want to make it possible for supervisors to call into an active call without interrupting the call between the agent and customer.

Twilio evangelist here.
I believe that when making SIP calls, the From parameter will take any alphanumeric string so you can just provide the customers caller ID as the From value:
$call = $client->account->calls->create($_REQUEST['From'], "sip:agent#example.com", "http://www.example.com/conference.xml", array());
echo $call->sid;
Hope that helps.

Related

Twilio API Conference: How to start a participant in hold mode

I want to start a conference with 3 participants:
Client
Agent
Supervisor
Where the client would "enter" the conference in hold=true mode.
I did not find in the twilio api documentation how to do that, there is a possibility to start him in mute mode, but that does not serve our needs.
What i could do is to start the conference and then immediately put the client into a hold mode.
But is there is a proper way to do this?
Thank you.
Twilio developer evangelist here.
There is no way to start a participant in hold. But a conference participant on hold is not really participating in the conference.
Could you keep the user waiting by sending them to TwiML that just returned hold music using <Play> until you want to bring them into the conference by redirecting the call?
Alternatively your suggestion to have them join the conference, then immediately send them to hold will work for you.

Twilio IVR Database Integration Two Inputs?

I have played around with database integration on Twilio, but how would I be able to ask for two inputs such as tracking number and password, and then for a status to be read if both are correct?
My main aim here is to protect our clients who need to get updates on their cases so that others cannot just randomly press a load of numbers and inadvertently get someone's update messages.
Do you have any coding example?
I've been adapting their PHP examples which are given in their How-to guides.
Thank you very much in advance for your help,
Dan
Twilio evangelist here.
So the pattern you can use in this scenario is basically something like this:
An inbound call causes Twilio to request the URL you have specified for your Voice Request URL. That URL returns TwiML.
https://www.twilio.com/docs/api/twiml
Maybe the <Say> verb telling Twilio to prompt the user for the first input (lets say tracking number) and the <Gather> verb to listen for the caller to enter tones. As part of the Gather verb you need to include the action parameter which tells Twilio what URL to request once the Gather completes.
<Response>
<Gather action="/gather-tracking-number.php">
<Say>Please enter your tracking number</Say>
<Gather>
</Response>
Once the user enters their tracking number and the Gather completes, Twilio will request the URL specified in the Gather verbs action parameter. As part of the request Twilio will pass you the digits the caller entered. Your app needs to persist those somehow. Database, session, whatever.
This URL also needs to return TwiML with the next prompt in it.
<Response>
<Gather action="/gather-passcode.php">
<Say>Please enter your customer pass code</Say>
</Gather>
</Response>
Also, as a cheap way of maintaining state across the request/responses, you can use the querystring. For example to pass the tracking number to the next page in your workflow you can throw it in the URL like this:
<Response>
<Gather action="/gather-passcode.php?trackingnumber=" . _REQUEST["Digits"]>
<Say>Please enter your customer pass code</Say>
</Gather>
</Response>
Hope that helps.

Twilio - How to dial third party number and add him to conference?

I am facing a small problem while using Twilio conference.
My API gets incoming call and puts caller to new and empty conference room:
<Response>
<Dial>
<Conference waitUrl="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient">Conf 1</Conference>
</Dial>
</Response>
So I got caller waiting in an empty conference room and listening music.
I want to dial some other number and to add it to this confrence room.
That number is non-twilio.
How can I do this?
You could use the Twilio REST API to make an outbound call, and direct that call into your conference room. In PHP this can be done like this:
(This is from the twilio-php helper library)
require('/path/to/twilio-php/Services/Twilio.php');
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create(
'some-twilio-number', // From a valid Twilio number
'other-number-to-call', // Number to call
'http://example.com/some_twiml'
);
The URL you use here should serve TwiML that puts the caller into the same room as your original call (exactly as you have in your question). In effect, one person called you, then you called the other person and put them into the same room.
(In the interests of full disclosure, I worked for Twilio.)

Twilio call forwarding

I have a question about Twilio's call forwarding concept.
I want to create an application that lets users forward their existing numbers to Twilio, which processes the necessary information, and forwards the call back to the user.
However, when I try to implement this, an infinite loop happens: The call is forwarded to Twilio, which forwards the call back to the user, which forwards the call to twilio...
How would I implement this on the Twilio side, since it is difficult to implement any code on the user side?
Here is my code on Twilio that forwards the call back to the user.
<?php
header("content-type: text/xml");
?>
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Response>
<Say>Hello User</Say>
<Dial>+1973XXXXXXX</Dial>
</Response>
This is tricky. How are users forwarding their existing numbers to Twilio?
The problem is that you want a rule for your cellphone like, "Forward all calls from my cellphone to my Twilio number, unless they are coming back to my cellphone from Twilio." I'm not sure if the call forwarding mechanism for your existing numbers is that sophisticated.
On the Twilio side, you could try returning different TwiML based on whether you've "seen" the call before (is it being forwarded for the first time, or the second time)? But you would have to forward the call to a third number, to avoid the forwarding problem you are already running into.
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. Conditional call forwarding can only be used for unanswered or busy calls, and for some providers, certain numbers. However, AT&T and Verizon do not allow "forward all numbers but one" for call forwarding.
you are working with twilio call it is with the best solution that we have:
"But you would have to forward the call to a third number, to avoid the forwarding problem you are already running into."

Twilio's receive sms and send a call..

I am trying to do this but it is not working....I was trying to text to my sandbox sms at Twilio so once twilio receive's that sms it would execute a script that should dial a number. This is not working as I get no error so I am assuming the only place where the Dial verb works is in the phone section of Twilio and not the sms part. Any help?
I want the sms to be a trigger that starts up a script which uses Twilio's dial verb to call people and give a message then hang.
The <Dial> verb is a top level one, so it should be a child of <Response>, i.e., not <Sms>. That said, Twilio's documentation strongly implies putting <Dial> in the <Response> for an SMS callback won't work; <Dial> is supposed to connect a current caller to another party. So, if this isn't working, you'll hit their REST API to initiate the call; you can POST the TwiML script with the message to speak and the instruction to then hang up.
Note this contradicts my first reply to your comment on your other Twilio question, my apologies for that.

Categories