0

I want to pass a parameter via URL for TwiML to read from when it addresses the person on the other end of the phone. I can't seem to get it to work right. I've tried all sorts of things.

Here is my ASP.NET VB Code...

Dim XClient As New TwilioRestClient(accountSid:=accountSID, authToken:=authToken)
XClient.InitiateOutboundCall(from:=From, [to]:=SendTo, url:="http://mywebsite.com/TestURI.xml?test=Todd")

Here is my XML...

    <?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="alice">$test</Say>
    <Pause length="1"/>
    <Say voice="alice">Do you enjoy hotdogs? I do.</Say>
    <Pause length="1"/>
    <Say voice="alice">Please work so that I can enjoy my lunch in peace!</Say>
</Response>

How do I get this TwiML script to report "Todd" from the URL? Any help is much appreciated. Thank you!

2 Answers2

1

TwimL Bins has has the concepts of templating you can leverage (and also not have to host the TwiML on your own servers).

How to use templates with TwiML Bins

https://support.twilio.com/hc/en-us/articles/230878368-How-to-use-templates-with-TwiML-Bins

Pass in the URL parameter and then reference it in the TwiMLBin as a Template.

   <Say>{{Test}}</Say>

You can also use Twilio Functions (Node),https://www.twilio.com/console/runtime/functions/manage, with JavaScript ES6 template literals to do similar:

exports.handler = function(context, event, callback) {
    let twiml = new Twilio.twiml.VoiceResponse();
    let testParam = event.test;
    twiml.say(`Hello ${testParam}`);
    callback(null, twiml);
};
Alan
  • 10,465
  • 2
  • 8
  • 9
0

What you'll need to do is generate a dynamic XML (TwiML) response that can incorporate any query parameters into the XML response. I don't know ASP.NET or Visual Basic very well, but most web programming languages have a way to generate dynamic responses in response to HTTP requests.

Here's an example in the Twilio docs of how to generate a TwiML response from an ASP.NET MVC application - it might not be precisely the same technology you are working with, but it might help you get pointed in the right direction:

https://www.twilio.com/docs/voice/quickstart/csharp?code-sample=code-make-an-outgoing-call-using-twilio-and-c&code-language=C%23&code-sdk-version=5.x

Kevin Whinnery
  • 1,209
  • 10
  • 11
  • I've looked at this document a dozen + times. I have my application calling me and texting me. The issue I am dealing with is handing off custom parameters. What you supplied isn't helpful at all. Sorry. Generating dynamic XML to the output folder might be a possibility but it isn't ideal. There's no way to get TwiML to read from a URL and process the XML? – user2951331 Mar 08 '19 at 18:59