I want to implement one functionality in VoIP call using twilio. Like if someone is calling to the customer care numbers and in that case they have to dial some numbers to navigate like dial some number choose language and dial some number to talk to representative.
So, to implement this in my application with VoIP call, I have tried this so far.
Here is my generated TwiML response at the time of VoIP start
<Response>
<Dial timeLimit="7200" callerId="+19782880482" record="record-from-answer-dual">
<Number statusCallbackEvent="initiated ringing answered completed" statusCallback="http://0affe80b.ngrok.io/call/twilio/events" statusCallbackMethod="POST"></Number>
</Dial>
<Record timeout="10" maxLength="7200"/>
</Response>
And in frontend part, on each digit press I am sending a digit to current active connection like this,
function onNumberPress(number){
var connection = Twilio.Device.activeConnection();
connection.sendDigits(number);
}
But, now at the time of sendDigits function, I am getting this error
TypeError: a.match is not a function
at a.sendDigits (twilio-1.3.21.min.js:19)
Note: I am able to get active connection here.
After surfing I found that I need to supply Gather keyword in TwiML. But do I need to pass those in this case? I think its not needed in My described case.
Am I on right track? Is this possible to achieve? If then what am I missing here?
Twilio developer evangelist here.
The connection.sendDigits function takes a string as an argument (as it can be any digit as well as # or *). I think you may be passing a number to it instead. Try ensuring that the digits you send are strings.
Related
We've got a basic twiml set up that sends a call to multiple destinations, it looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Number>+1800XXXXXXX</Number>
<Number>+1912XXXXXXX</Number>
</Dial>
</Response>
The problem is I want to have one of the destination parties press a digit ( like "1" for example ) before twilio actually bridges the call to them.
I've looked at but that only seems to get digits from the caller, not the callee.
Twilio developer evangelist here.
To have the recipient of a call started by a <Number> perform an action, you need to provide a URL as the url attribute of the <Number>. When the call connects, Twilio will make a webhook request to that URL and you can return TwiML from the URL. Within that TwiML you can include a <Gather> to have the recipient enter a digit before you connect the call. See the documentation for the url attribute for <Number> for more detail.
How to transfer a in-progress call to another number.The concept that I m using is to use the update method when the call is in in-progress and dial the number that I wanted To connect and It is working but the connection with the first caller is breaking/
Code for the process of transferring call-
1.process for dialing call-
<Response>
<Dial callerId="callerid">
<Number statusCallbackEvent="initiated ringing answered completed" statusCallback="urltohadlestatus">user_number</Number>
</Dial>
</Response>
2. process to process to transfer the call-
I have used the update method to transfer the call.
function update_call1($CallSid, $admin_no) {
$rr = array(
"url" => "trurl?admin_no=".$admin_no,
"method" => "POST"
);
$call = $this->client->calls($CallSid)->update($rr);
return $call->to;
}
and used this TwiML
<Response>
<Dial>admin_number_call_to_be_transfered</Dial>
</Response>
what this does is transfer the call but when admin receives it,It disconnects the call.
And what I need like when jack make call to jenny and now jack want to transfer the call to jhonny and when call is transferred to jhonny, jack shound be disconnected from the call.
Twilio developer evangelist here.
You have two options here. Once the call is transferred away, the other caller will drop if it has nothing else to do. There are two ways you can achieve this.
You can either put the callers in a <Conference>. Then when the caller is transferred the other call remains in the conference room. There is a good tutorial on warm transfers using this technique, which might help.
Alternatively, if the side of the call that is dropping out right now is the one that generated the call from the Twilio REST API you can add more TwiML below the <Dial> verb to have the call continue. For example:
<Response>
<Dial>OTHER_NUMBER</Dial>
<Say loop="0">You are still on the call.</Say>
</Response>
Will just keep saying "You are still on the call" once the other end is transferred away.
You can also achieve this with the action attribute for <Dial>. Using the action attribute means that Twilio will make a webhook request to the URL you specify and use the TwiML from that response to carry on the call.
I am trying to make call from my app to phone, My app executes a POST Request in which i am passing following parameters.
CallUrl = “https://api.twilio.com/2010-04- 01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Calls.json”
From = “+MyTwilioNumber”
To = “+9179XXXXXXXX”
Url = “myserveraddress.com/data.xml”
AuthToken = “cdXXXXXXXXXXXXXXXXX”
AccountSid = “ACXXXXXXXXXXXXXXXX”
Url Returns-
<Response>
<Dial>
<Number>+9179XXXXXXXX</Number>
</Dial>
</Response>
Now what happens is that when call is received, I hear the number you are trying to call is busy.
Can anybody help me what’s going wrong ???
Also how can I get call status in my App like call is ringing, answered, disconnected ???
Twilio developer evangelist here.
It sounds like you are making the call correctly and just dialling a busy number. If that's not the case, then let me know and I'll see if I can help further.
As for getting events for when the call is ringing, answered, disconnected etc, you need to check out the statusCallback parameter. You pass a URL to get webhooks when the statuses you want to hear about (chosen via the statusCallbackEvent parameter happen.
Let me know if that helps at all.
I know that on making a call Twilio can detect an answering machine, and react differently.
However if I use the <dial> verb, there's no obvious place to add this feature, even though it's essentially the same thing.
My intended flow is:
Customer enters their phone number
Twilio calls Customer and plays a voice message
Twilio dials an agent number, likely a mobile
If the Agent picks up, connect the customer to the agent
If the Agent busies the call or does not answer, call will likely go to Agent's voicemail.
Terminate call to Agent
Record voicemail from Customer
Email voicemail to Agent
From the official docs on the <Dial> verb (emphasis mine):
This is the simplest case for Dial. Twilio will dial 415-123-4567. If someone answers, Twilio will connect the caller to the called party. If the caller hangs up, the Twilio session ends. If the line is busy, if there is no answer, or if the called party hangs up, <Dial> exits and the <Say> verb is executed for the caller before the call flow ends.
<?xml version="1.0" encoding="UTF-8"?>
<!-- page located at http://example.com/simple_dial.xml -->
<Response>
<Dial>415-123-4567</Dial>
<Say>Goodbye</Say>
</Response>
Placing a <Record> verb after the <Say> verb sounds like what you are looking for. You can change the timeout from the default value of 30s like this:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial timeout="9001">415-123-4567</Dial>
<Say>Please leave a message</Say>
<Record action="/process_new_voicemail" />
</Response>
I am sure this is late, but hopefully it helps some one out. It sounds like you may just need to screen the call.
Basically, you can ask the "agent" that you dialed to accept the call and hang up if you do not receive input.
I am not sure what language you are using, but here is a great php/Laravel tutorial to explain:
https://www.twilio.com/docs/tutorials/walkthrough/ivr-screening/php/laravel
The key part is here:
$dialCommand = $response->dial(
['action' => route('agent-voicemail', ['agent' => $agent->id], false),
'method' => 'POST']
);
$dialCommand->number(
$numberToDial,
['url' => route('screen-call', [], false)]
);
Notice that the dial command uses the 'action' to specify a location that is sent a POST request should the call end i.e POST to /agent-voicemail.
Then, the number is dialed along with a 'url' parameter this is the location that will be requested after the agent has picked up but before connecting the two parties.
The /screen-call route then asks the agent to accept the call, if no input is received it hangs up and will make a POST request to the initial setup /agent-voicemail route.
This method will handle your scenario because if it goes to voicemail no input will be received and the call will end.
After searching I could find a TWIML noun 'sendDigits' which sends digits to the destination number like following:
<Dial record="true" callerId="415-123-1111">
<Number sendDigits="wwww1928">
415-123-4567
</Number>
</Dial>
What I need is to send digits to the 'CallerId' (we need to use callerId's which are already in extension system locally). I could find nothing in TWIML References for this.
Can anybody please tell me a work around to send Digits for 'CallerID'.
Thank you
Twilio employee here. I think I understand what you're trying to do: you want to connect person A (phone number + extension) to person B (phone number + extension). Is this correct?
If so, you're half way there, you've essentially coded the 2nd half of the call (to person B). But you need to use the REST API to initiate a call to Person A. The API call takes 3 parameters:
To - the phone number for person A
From - the caller ID you want person A to see when their phone rings (usually a Twilio #)
URL - the URL to your TwiML
The TwiML you send to Twilio should look something like this:
<Play digits="12345"/>
<!-- at this point you've successfully connected to Person A -->
<Dial record="true" callerId="TWILIO NUMBER HERE">
<Number sendDigits="wwww1928">
415-123-4567
</Number>
</Dial>
<!-- at this point you've successfully connected to Person B -->
The key thing to remember is that connecting a call between two people is a 2-step process: first use the REST API to establish a live call to the 1st person and then use TwiML and to establish a live call to the 2nd person. Then Twilio bridges them together.
Hope this helps!