How to pass in a custom parameter to TwiML Bin? - twilio

I have some issues trying to pass a custom parameter to TwiML Bin. See attached pictures.
Everything works except the paramter.
Any ideas of what I am doing wrong?
Setup:

Twilio developer evangelist here.
ApplicationSID is from TwiML applications which are containers for a set of URLs and configurations that tell Twilio what to do when one of your Twilio numbers receives a call or SMS message.
If you're using dynamic content from custom HTTP request parameters (ie. name in this case), you should take your TwiML bin's URL and pass it the Name parameter like this in, for example, Python, to generate a call with the custom parameters:
client.calls.create(
url="your-twiml-bin-url?Name=Jeremy",
to="your-phone-number",
from_="your-twilio-phone-number")

Related

Twilio Gather followed by call forward (Dial) after user input without using another webhook

I'm using the Twilio C# SDK to initiate an outbound call from Twilio, during which user's DTMF input needs to be gathered (Press 1 to be transferred to sales, 2 for support...), and the subsequent action is to forward the call to a designated E164 number that matches the key.
So the VoiceResponse.Gather() method takes this action parameter that is a webhook Uri to which the user input will be posted and we can surely forward the call from there.
var twiml = new VoiceResponse();
twiml.Say("...");
twiml.Gather(numDigits: 1, action: webhookUri);
But is there a way to achieve this simple forward instruction within the current twiml object without involving an external webhook? Basically something that gathers the user input digit, correlates to a E164 number(using a predefined dictionary), then Dial directly.
Twilio developer evangelist here.
No, there is not a way to achieve the instruction after the <Gather> without another webhook. You must pass a URL as the action parameter and respond to the webhook with the next set of TwiML to direct the call onward.
If you do not want to host the application that responds to this webhook yourself, you could achieve this flow using Twilio Studio, which is a drag and drop editor for communications flows, or using Twilio Functions, which is a serverless environment where you can respond to incoming HTTP requests with JavaScript functions.

Is it possible to send twiml content rather than pointing to a URI when initiating a Twilio call

When i make a call as voice content to that call, can i send a dynamically generated twiml message rather pointing to a URI that contains twiml message ?
If not is there a a workaround to accomplish this , cause I see DIAL and SAY APIs which get used during call response, so would it be possible to make use of those when creating a new call and passing twiml messages using these APIs ?
https://www.twilio.com/docs/api/twiml/dial
https://www.twilio.com/docs/api/twiml/say
Twilio evangelist here.
Its not possible to send TwiML to the REST API. If you don't want to host the TwiML on your own URL there are a few options:
Use TwiML Bins which lets you host relatively static (there is some templating support) TwiML on Twilios servers.
Use Twilio Functions which let you write, store and execute Node on Twilios servers
Use Twilio Studio to define your call flow. A flow in studio can be triggered via an HTTP request to it, so you can take the flows URL and pass it to the REST API when you start your outbound call.
Hope that helps.

Twilio: statusCallBack?

Need some Twilio help. I am a novice and I'm kinda lost. This may seem overly simplistic BUT I have a CRM client that will track calls as long as the inbound calls ping the URL - x2vps.com/index.php/api/voip/data/{caller id goes here}
Note: The CRM will automatically track all registered phone numbers that ping this URL.
I have the call routing piece figured out. I can't figure out how to code twilio's API to append the inbound caller ID's to the CRM's URL and ping it. I want to log all calls regardless of the status.
If you could point me in the right direction I would be truly appreciative.
Thank you!
Twilio developer evangelist here.
Twilio does not append the caller ID to the webhook URL that you set. In order to do something like this, you'd need to provide some sort of server in the middle that can transform the Twilio request into the format you need.
You'd do this by creating a web application that would be able to receive the webhook from Twilio. It would then need to get the incoming Caller ID from the Twilio request, this is the From parameter. With the Caller ID, your application would then construct your CRM endpoint URL and make the HTTP request itself. You'd need to decide whether you need to include all the original parameters, if the CRM system can use them.
Let me know if this helps.

Is there a way to display Twilio number in Caller ID without hard-coding it?

I have a question similar to this one:
How can I display my Twilio number for inbound calls
However, I now have two separate Twilio numbers that both point to the same URL, so hard-coding the number as Caller ID is no longer an option. Is there a method I can use to get which Twilio number was called? I know that PhoneNumber gets the caller's number, so I need a way to distinguish which of my two numbers are calling.
Twilio evangelist here.
When Twilio makes its HTTP request to your application letting you know that someone has called your Twilio number, we pass along a bunch of form-encoded parameters, including which Twilio phone number the person called. Your web platform should have a way to grab those parameters fro mthe incoming request. For example in PHP it looks like this:
$from = $_REQUEST['To'];
In .NET, there are a number of ways to do it, but here is one:
Request.Form["To"]
Hope that helps.

How can I retrieve and save Twilio responses in Rails?

So a user calls a Twilio phone number. Twilio looks for a voice_url attached to that number (from their dashboard) and sees some XML with instructions on how to handle the call. The XML file also has an "action" parameter that points to a url.
Ideally, this URL should be able to retrieve parameters sent by Twilio and save them to a DB. This is where I'm stuck; how can I see which parameters are sent and how can I save them? I'm assuming the URL in the "action" parameter points to a controller?
I'm using the twilio-rb gem.
Some relevant links:
http://www.twilio.com/docs/api/twiml/dial#attributes-action
http://www.twilio.com/docs/api/twiml/twilio_request
When Twilio makes a POST to the URL mentioned by the Action parameter, it will send all of the attributes mentioned here: http://www.twilio.com/docs/api/twiml/twilio_request.
You should create your own route and controller for responding to the incoming Twilio request. When Twilio makes the request, you should be able to get the variables out of the POST request like any POST request. See for example How to access POST variables in Rails?.

Resources