Twillio sendDigits for CallerID (outbound calls) - twilio

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!

Related

simulring and collect digits from dialed number to accept call

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.

Twilio call forwarding one after another - how to disconnect if person picks up the call

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say> Connecting call to Pinto </Say>
<Dial record ="record-from-answer" timeout="10" hangupOnStar ="true">
<Number>XXXXXXXX</Number>
</Dial>
<Say> Pinto is not picking up the call, now connecting call to Management </Say>
<Dial record ="record-from-answer" timeout="10" hangupOnStar ="true">
<Number>XXXXXXXX</Number>
</Dial>
<Say> No one is picking up right now. Please text us at +12022171828 </Say>
</Response>
Above is the call forwarding flow for one after another.
What I'm looking here is,
If 1st user attended the call, then it should not initiate the call to 2nd number and also it should not say text message which is at last line
If 1st user disconnected, then redirect call to 2nd number - if 2nd number not picking up the call then it should say text message which is at last line
if 1st user disconnected, then redirect call to 2nd number - if 2nd number picked up the call then it should not say text message which is at last line
Also I want to Implement Transcribe & Transcribe call back by using TwiML.
So, please help me like how we need to do with that?
To carry out this flow, you cannot perform the entire thing in one TwiML response. Instead, you will need to provide the <Dial> element with URL in the action attribute so that once the first call completes, Twilio makes a webhook to find out what to do next.
So, your first TwiML response should look like:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say> Connecting call to Pinto </Say>
<Dial record="record-from-answer" timeout="10" hangupOnStar="true" action="/complete">
<Number>XXXXXXXX</Number>
</Dial>
</Response>
Above I've added action="/complete" to the <Dial> and this means we need an application to be able to respond to HTTP requests to /complete as well. We also need this to be an application and not a static response as we need to work out whether the call was answered or not and decide on what to do next and what TwiML to respond with.
We can do this because one of the parameters that Twilio sends to the action URL is DialCallStatus. This parameter can be "completed", "busy", "no-answer", "failed" or "canceled" and this tells you what happened in that first call.
So, in your case, you will want to check the DialCallStatus and if it is "completed" then you do not need to return the next <Say> and <Dial>. If, however, the DialCallStatus is one of the other statuses, you do want to return the next <Say> and <Dial>. That <Dial> should include another action URL that makes the same choice at the end of the second <Dial>.
I'm not sure what language you are building with, but a pseudo-code idea of this would look like this:
post '/complete' do
if params["DialCallStatus"] != "completed"
return "<Response><Hangup/></Response>"
else
return "<Response><Say>Pinto is not picking up the call, now connecting call to Management</Say><Dial ....></Response>"
end
end

Receive Simulteneous Call to Twilio SIP End Points from a Single Phone Number

I have a phone number and a SIP domain on Twilio. So when I receive a call on phone number all the SIP endpoints must ring simultaneously and once the call is received by any SIP end point, the ring to other numbers must stop. I want more or less a configuration of a call center. I am able to call a single SIP endpoint but not multiple.
Secondly If multiple simultaneous rings to SIP end points are not possible through twilio, then I want to use Asterisk, so please guide me is it possible using asterisk to receive a call on one number and forward it to multiple SIP end points.
Asterisk:
exten => 600,1,Dial(SIP/100&SIP/101,,o)
; call to 600 to get two calls to 100 and 101 endpoint.
Twilio:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Number>877-555-1212</Number>
<Number>877-999-1234</Number>
<Number>877-123-4567</Number>
</Dial>
</Response>

Twilio JS send digits in VoIP call

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.

Twilio unable to forward/transfer call

I have an app that dials a phone number, gives a set of instructions, and then forwards the call to a specified phone number. Currently when I press the digit to transfer the call it just pauses and hangs up. Not sure what im doing wrong.
This is the initial instructions. If the number 1 is pressed it is supposed to transfer to transfer.xml, which is under # 2.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather timeout="10" action="http://1.1.1.1/twimlet/transfer.xml" numDigits='1' finishOnKey='1'>
<Say>"Dummy Text Dummy Text"</Say>
<Say>"Please press 1 to transfer this call. Or nothing to hang up."</Say>
</Gather>
</Response>
If the caller presses #1 then it is supposed to send them to this xml file, and transfer the current call to the number under dial. But currently it just hangs for 2 seconds and drops the call.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>"Transferring you to a court clerk"</Say>
<Dial timeout="60" callerID='+14393523419'>
<Number>8125277222</Number>
</Dial>
</Response>
Am I doing something wrong with my xml? Not sure why it is dropping.
Twilio developer evangelist here.
Your action in your <Gather> is pointing towards the URL http://1.1.1.1/twimlet/transfer.xml. That looks like a local network address rather than a publicly available URL. If that IP address is not available to Twilio, then the call will not be able to continue.
Try using relative URLs instead of absolute ones. Twilio will happily follow the path /twimlet/transfer.xml.
Let me know if that helps!
Hm could it be because finishOnKey is set to 1 in your <Gather> verb? So, it's taking it as you end the call? Have you tried setting it to finishOnKey=""?

Resources