What is the difference between DialCallStatus and CallStatus? - twilio

What is the difference between DialCallStatus and CallStatus?
I saw when you use Dial verb with the action attribute, we can get the DialCallStatus and the CallStatus, what is the differences between these values?

Twilio evangelist here.
DialCallStatus tells you the status of the call intiated by Twilio when you use the <Dial> verb and will only be included as as an HTTP parameter when Twilio requests the URL you have specified in the <Dial> verbs action attribute.
So for example, if you make a phone call into a Twilio number you can see what the CallStatus for that particular call is. Once that call connects, if you then use the <Dial> verb to have Twilio make a outbound phone call and bridge it to the first call that second call has its own status, which is communicated to you using the DialCallStatus parameter. This is because when the second call ends, the first call can continue on if you tell it to.
Does that make sense?
Hope that helps.

Related

Twilio IVR request parameters

I am using ExecutionCreator to use twilio IVR call service
Execution execution = new ExecutionCreator(pathFlowSid, new receiverPhoneNo, new senderPhoneNo)
.setParameters(request.getParametersMap()) //setting request params
.create(twilioClient);
Now I want to get the status of the IVR call and this is done by using Call resource and using statusCallback parameter as given in this https://www.twilio.com/docs/voice/api/call-resource#statuscallback, but there is no way of setting request parameters on Call resource as was possible with Execution resource(please refer to code added).
Is there any way I can get both these functionalities like statusCallback as well as setting request parameters ?

Twilio Voice API - Use "inline" TwiML instead of XML url when creating outgoing call

I'm using the Twilio Voice API to create an outbound call:
$call = $twilio->calls->create(
"+14155551212", // to
"+15017122661", // from
array(
"url" => "http://demo.twilio.com/docs/voice.xml"
)
);
As you can see, the script used for the call is accessed with the "url" parameter pointing to a XML file.
The XML is hard coded though. Is there a way to write "inline" TwiML inside this create function so I can pass in PHP directly to make the script dynamic? Then I wouldnt be using a hard coded XML file but dynamic PHP instead.
For example, if I have:
$customer_name = $customer['name'];
I'd like to be able to pass this into the script to be read when a listens to the call.
How can I accomplish this?
Twilio developer evangelist here.
There is currently not a way to create a call and directly give it static TwiML to execute.
If you don't want to host static TwiML you could choose to host your TwiML in Twilio's TwiML Bins.
If you want the TwiML to be dynamic, but you don't want to host it yourself, you could use Twilio Functions to respond to your webhook.
Let me know if that helps at all.

Twilio action for record

I'm trying to create a Twilio workflow that places a call and records what the user says. For that I'm using Record, but I'm not entirely sure what to place in the action parameter.
Even though I understand Twilio will send information about the call to that URL, I don't necessarily require it. Is there a way to have some sort of a sinkhole for information?
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="woman">Hi! Say your name:</Say>
<Record method="GET" action="URL_here" timeout="2"/>
</Response>
I don't think there is another option but to create a bin or another endpoint and return an empty response like:
<?xml version="1.0" encoding="UTF-8"?>
<Response />
If you omit the action attribute you'll end up with a loop which is probably not what you're looking for.
The 'action' attribute takes a relative or absolute URL as a value. When recording is finished Twilio will make a GET or POST request to this URL including the parameters below. If no 'action' is provided, will default to requesting the current document's URL.
After making this request, Twilio will continue the current call using the TwiML received in your response. Keep in mind that by default Twilio will re-request the current document's URL, which can lead to unwanted looping behavior if you're not careful. Any TwiML verbs occurring after a are unreachable.
(https://www.twilio.com/docs/voice/twiml/record?code-sample=code-using-attributes-in-a-record-verb&code-language=output-twiml)

How to pass parameters in Twilio's outbound calls?

I believe Twilio's outbound call could be HTTP POST request. Is there a way I can pass my custom POST body (json etc) when making outbound voice call request? I'm writing a generic call center where I would like to pass the conversation workflow when making outbound calls so that the code which receives the call knows how to run the conversation. I looked at the documentation (https://www.twilio.com/docs/api/twiml/twilio_request) and looks like we can only pass standard parameters (from, to etc). Thanks for any help.
I believe the only parameter you can customize is the Url Parameter.
Your JSON is pretty much a string (you might have to url encode it and also watch for the length), but you could put it in the query string of the Url Parameter.
?json=url_encoded_json

Twilio Outgoing Call - Twiml url

in the basic Twilio outgoing call, there is one parameter to be set which is the url, like this example:
call = client.calls.create(to="+14085551234", # Any phone number
from_="+12125551234", # Must be a valid Twilio number
url="TwiML-app-url")
Here is the TwiML file that is being passed in my url:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="**my-ruby-script**" method="get">
<Say>Please choose a number then press the pound sign</Say>
</Gather>
</Response>
How can I handle the action with a ruby script? The ruby script needs to get the digit that is inputed by the user, then generate a new TwiML response based on that input.
Ricky from Twilio here.
In order to do this you'll want to make sure your ruby script is available via publicly accessible URL. Since you specified GET as the method for your action Twilio will send the digits the user pressed in the query string in the parameter named Digits. Then you can use the Ruby helper library to generate the TwiML you want to respond with.
You didn't mention if you were using a framework so I'll show a snippet using Sinatra but the general idea would apply in other frameworks as well.
require 'twilio-ruby'
require 'sinatra'
get '/process_gather' do
# params['Digits'] <- here is where the button the user pressed will be stored.
# You can do a conditional check here as you see fit.
response = Twilio::TwiML::Response.new do |r|
r.Say 'hello there', voice: 'alice'
end
response.text
end
Hope that helps!

Resources