TwiML Bin - Anyway to access parameters?

2019-05-23 07:31发布

I am setting up a demo for a product, and we are using Twilio two connect two people together. To host the XML response, I set up new TwiML bin files that Twilio offers. I am using the <Gather> call to prompt the first caller to hit 1 to accept or 2 to decline.

Is there anyway to check the Digits parameter from the Gather in a TwiML bin file?

标签: xml twilio twiml
1条回答
Deceive 欺骗
2楼-- · 2019-05-23 08:28

Twilio developer evangelist here. Unfortunately, to get the value from the <Gather>, you will need a backend server as Twilio will make and HTTP POST or GET request to your page with that digit.

Luckily doing that is pretty simple, and you could put something in place fairly quickly by just deploying it to one of your servers, or even a free Heroku instance.

From your question, I can't quite tell what programming language you're using, but if you wanted to do this in say PHP, you could do something like this:

<?php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<Response><Say>You entered " . $_REQUEST['Digits'] . "</Say></Response>";
?>

Another way you could do this is by using the twimlets website.

Have a look at this example. You could then create your logic with TwiMLBin to redirect the user.

Hope this helps you out.

查看更多
登录 后发表回答