Twilio Call Issue from iOS App to Phone - ios

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.

Related

How to collect the user input when make a call using Twilio API?

I am developing a simple application in C# which
Trigger a call using Twilio
receiver to press * after receiving the call and finish the call after pressing *
Provide the status completed if user pressed * otherwise provide different status.
I was able to make a call but not able to receive the user input Or status, I tried finishOnKey() but that didn't work, and it always provides status as completed. I didn't get much help from Twilio code sample, can someone redirect to correct article or provide the code to accomplish above.
Twilio developer evangelist here.
Once a call is answered successfully, it doesn't matter how the call is finished, the final status it reaches will be "completed". You can see more about Twilio call statuses in this documentation. You can see that the final call statuses could be:
completed: call was answered successfully and then finished
no-answer: Twilio dialled the number but there was no answer before the timeout
busy: Twilio dialled the number but received a busy signal
cancelled: The number was dialled, but the call was then cancelled using the API before answering
failed: the carrier couldn't connect the call
If you are using <Gather> to take the user input, you should ensure you have set the action attribute to a URL in your application. That URL will receive a new webhook request when the user presses a digit. For example:
<Response>
<Gather action="/gather_results" digits="1">
<Say>... your content goes here ...</Say>
</Gather>
</Response>
With the above TwiML a user would only have to press 1 key before the call is moved to the next stage and the webhook '/gather_results'.
The request to the /gather_results endpoint would include a body with a Digits parameter. If the user pressed "*" then the body of the request would include Digits=*, if the user pressed "1" then it would include Digits=1. You could then choose to do whatever you like with those results, including hanging up the call or recording the submitted digits.
Let me know if this helps at all.

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.

Retrieve Key Input before recording a users call when making calls within Twilio

We have currently developed a phone system for our call centre using Twilio (mainly c#, angular2 and typescript). Our company is currently in the UK but we have now started expanding out to the USA and because of laws in the US it looks like we'd need the ability to choose when we turn on the call recording. In the US people have to consent to recording the call before you can start recording them. I am trying to - when we make an outbound call via twilio to first play a message and get the user to input a key on their dialer to consent to recording the call before continuing with the call. I have attempted to use the gather and say verbs after we have dialled out but this doesn't seem to work. Code below:
`
public override void ApplyAction(TwilioResponse response)
{
var attributes = this.GetAttributes<DialAttributes>("attribute-");
attributes.callerId = this.PhoneNumber;
response.Dial(new Number(this.ReceiverPhoneNumber), attributes);
response.Gather(
new
{
timeout = 10,
finishOnKey = '*'
});
response.Say("We record all calls - please press the star key to consent to call recording");
}`
Twilio developer evangelist here.
The problem is that you are performing the <Dial> before the <Gather>
and <Say>. If you want the user to approve the call first you need to nest the <Say> in the <Gather> and provide an action URL for the <Gather>. When the user presses a button as part of the <Gather> Twilio will make an HTTP request to the action URL with the results in the Digits parameter. Then you should return the <Dial> as the response to that request, if the user signifies agreement. This way you ask them first and then connect the call.
Let me know if that helps.

Twilio, How to transfer a in-progress call to another number

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.

Call method for Twilio on Parse Cloud Code

We are trying to implement simple P2P VoIP connection between iOS devices. We picked Twilio to handle calls and using Parse to interact with Twilio.
We are successfully generating capability tokens per user and initiate a call. However call is hanging up instantly after successful connection.
Receiver is receiving the call successfully and hearing the trial message.
Initiator is hearing the trial message and also "Application error occurred.".
We are suspecting that there may be something wrong at our call method on Parse Cloud Code.
app.get('/call', function(request, response) {
var client = require('twilio')('ACC_ID', 'AUTH_ID');
// Create a TwiML response generator object
var fromName = 'client:' + request.query.from;
var toName = 'client:' + request.query.to;
client.makeCall({
to:toName, // Any number Twilio can call
from: fromName,
url: 'http://xxxyyzz.parseapp.com/consult' // A URL that produces an XML document (TwiML) which contains instructions for the call
}, function(err, responseData) {
//executed when the call has been initiated.
console.log(responseData.from); // outputs "+14506667788"
});
});
We are not sure about what should url parameter supposed to do.
app.post('/consult', function(request, response) {
response.send();
});
Thanks.
You are almost there, but there seems to be a problem in your /call service (you also don't need any other urls, /call' should be enough).
What Twilio expects as a response from /call is a TwiML message (https://www.twilio.com/docs/api/twiml). Your server here should respond proper TwiML so that Twilio will know what to do.
If you want to connect two clients then /call should return the Dial TwiML message. The documentation (https://www.twilio.com/docs/api/twiml/dial) can let you know about the details of the Dial message. There are some interesting options such as limiting the phone call to 40 seconds for example.
If you want to dial a client called 'Jenna', then the response from your /call service should be:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Client>Jenna</Number>
</Dial>
</Response>
Good luck with your application, hope this helps!

Resources