TwiML Bin - Anyway to access parameters?

回眸只為那壹抹淺笑 提交于 2019-12-08 01:14:25

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/37258431/twiml-bin-anyway-to-access-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!