I have a twilio app: When someone calls the Twilio number and forwards it to a verified phone number. I'd like to know if that forwarded call was missed.
Is this even possible? Is it possible to do call progress events on forwarded inbound calls via Twiml? If so, what's the syntax?
I work with the devangels at Twilio.
It seems like you might be looking for the 'no-answer' Status parameter as seen here: https://www.twilio.com/docs/api/rest/call#call-status-values
Also looks like you're using PHP so the syntax would be something like this for a loop of calls:
foreach ($client->account->calls->getIterator(0, 50, array(
"Status" => "no-answer"
)) as $call
Related
I am trying to use the redirect instruction to take the customer and worker into a conference call in that is of fixed length (using timeLimit) but is variable in the sense that the timeLimit is determined by calling another function.
I am having issues understanding the documentation regarding this instruction. I know I must pass a call_sid and a url, but is the call sid the sid of the customers call to my number or the conference call I will redirect to and if it is the customer's call_sid how do I get it.
Also with the twiml url is this what I use to redirect the customer or worker to the call?
And where in this step would I create the conference call?
As you can see I'm lost regarding the API and would appreciate any guidance on where to look.
EDIT CODE:
exports.handler = function(context, event, callback) {
callback(null, {"instruction": "redirect",
"call_sid": "I DONT KNOW WHAT GOES HERE",
"url": "I DONT KNOW WHAT GOES HERE",
});
};
This is my assignment callback url but I don't know what the last two arguments are exactly asking for. This is the doc I'm using for reference at the bottom of the page https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks
Aim: Put incoming calls into conference.
What I would like to achieve is:
generate call signal to all available agents
put an incoming call into conference
when agent picks up, its connected to the conference
On an incoming voice call I have this code:
$response = new Twiml();
$dial = $response->dial([
'callerId' => $input['From'],
]);
$dial->client('testagent',
[
'url' => "/twilio/conference/create"
]);
How do I expand this twiml with an instruction to put an incoming call to conference, right after calls to agents are created?
Currently agent successfully resides in conference, while incoming call is still ringing...
Twilio Developer Evangelist here.
Couple of bits to understand about how the TwiML you're generating above works:
The <Dial> verb tells Twilio hold on to the call it just answered while we place an outbound call (to one instance of Client in your case). If that outbound call is answered, we will directly bridge those two calls together (no conference in between).
The TwiML returned by the url parameter you've included in the <Client> noun will get executed only on outbound leg we dialed and before Twilio directly bridges the two calls together. There is a limited subset of TwiML that you can return from that URL and unfortunately <Dial> isn't on of them: https://www.twilio.com/docs/glossary/call-whisper
Its possible to use a technique called a simuldial to have Twilio dial out to multiple agents: https://www.twilio.com/docs/api/twiml/client#examples-2. In this scenario whichever agent answers the call first will get bridged to the original incoming call. There is no conference involved in that scenario. Its a direct bridge but the direct bridge makes it pretty hard to do things like put a call on hold, transfer it to another party or add a third person. If you don't care about any of those scenarios then that might be an option for you.
If you do care about any of the above, I highly recommend using TaskRouter.
Hope that helps.
I managed to do this with an additional Twilio REST call and a route for agents
Added 'action' which executes after agent picks up a call and updates its leg:
$response = new Twiml();
$dial = $response->dial([
'callerId' => $input['From'],
'action' => '/twilio/conference/join',
]);
$dial->client('testagent',
[
'url' => "/twilio/conference/create"
]);
when agent route "/twilio/conference/create" is executed before sending dummy Twiml, I execute this Twilio Rest call:
$call = $client->account->calls($input['CallSid'])->fetch();
$call->update([
"url" => "/twilio/conference/join"
]);
This puts agent leg into conference, disconnects the caller which executes 'action' route on behalf of customer
I would really like to know why this couldnt be done with Twiml response on agent route...
I am looking into the possibility to implement call tracking with Twilio.
What I would need is that right at the start of an incoming call I would like to be able to change the destination number for that call.
How is this achievable with Twilio via API?
Reading the API docs I found the that there is a real-time call and message routing feature (here) and followed the example (here) but it's not what I would like to achieve.
Thanks ahead for any suggestion and help!
--Steve
Twilio developer evangelist here.
You absolutely can dynamically change the destination number for calls on Twilio. When you are forwarding calls you use the <Dial> noun in TwiML like so:
<Response>
<Dial>YOUR_NUMBER_HERE</Dial>
</Response>
However, if you serve your TwiML dynamically you can return whatever number in the <Dial> tag that you want, based on whatever conditions you want. For example in Ruby using Sinatra:
post "/voice" do
if params["From"] === SOME_SPECIAL_NUMBER
number = FORWARDING_NUMBER_1
else
number = FORWARDING_NUMBER_2
end
"<Response>
<Dial>#{number}</Dial>
</Response>"
end
Let me know if this helps at all.
Our application will make out calls to customers using different Twilio numbers. Here is our sample code:
r.Dial customer_number,
:method => 'POST',
:timeout => '30'
We want to add a caller id/number to all these numbers so customers could always see one number if we call them. Is such option available on Twilio? We purchased a verified phone number which could be used as caller number.
Twilio developer evangelist here.
If you have a verified number that you want to use as the caller ID then you just need to add one more attribute to your TwiML. The callerId attribute lets you specify the caller ID that will appear to the called party when Twilio calls.
You can update your TwiML to:
r.Dial customer_number,
:method => 'POST',
:timeout => '30',
:calledId => "YOUR_VERIFIED_NUMBER"
And your caller ID will be used for all your calls.
Megan from Twilio here.
If I am understanding correctly, it seems like this could be a good case for one of our Copilot features, Sticky Sender where Twilio will maintain a mapping of the To and From numbers.
Otherwise, the OutgoingCallerId instance resource represents a single verified number that may be used as a caller ID when making outgoing calls via the REST API and within the TwiML <Dial> verb. And there are some examples in Ruby there.
Let me know if this helps!
Edit: I stand corrected that the Sticky Sender feature only works with messaging services and not calling.
I'm developing a Rails Twilio-based application and want to show to my user the number that the caller is calling (because in my application, a user can be associated with multiple numbers).
Here's the code:
Twilio.Device.incoming (conn) ->
$("#log").text("Receiving call from:" + conn.parameters.From)
$("#log").text("Calling to:" + conn.parameters.To)
ringtone.play()
$('.answer').click ->
ringtone.pause()
# accept the incoming connection and start two-way audio
conn.accept()
However, the conn.parameters object does not have a To parameter as the documentation says.
For now, I can get the number being called only server side, with params["Called"], but that is not what I need.
Any ideas ?
Megan from Twilio here. I'd like to share some of what I learned after recently getting Twilio Client up and running.
The way I imagine your call flow is that a 'user' in your application represents an agent with multiple sales lines connected to Twilio numbers configured to a TwiML app. When a customer or the 'caller' finds one of those numbers and dials it, you want to display to the user-agent which of the Twilio numbers the customer is calling.
In the code above conn.parameters.To likely represents your default_client, if you specified one. But conn.parameters.From should actually display the number the caller is calling, which if I am understanding correctly is the desired behavior.
Hope this helps!