Reputation: 1
I'm trying to setup a simple call forwarding app using twiml only. The process flow I'm trying to accomplish is;
- Call twilio #
- say prompt to ask for the phone number to dial
- dial to that phone number
Reading the documentation it looks fairly simply to gather the number;
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action=“this is where the dial action goes” timeout="10" finishOnKey="*">
<Say>Please enter the phone number and press *.</Say>
</Gather>
</Response>
This should simply enough ask for a phone number, and log it as digits.
Next up the process should be to use dial to dial those digits, but that's where I'm a little lost. I've used dial several times, but not sure how to chain these two together.
<?xml version=”1.0″ encoding=”UTF-8″?>
<Response>
<Dial>
"the digits passed from gather"
</Number>
</Dial>
</Response>
Ideally I think it makes sense the dial command goes into the action="" section of the gather, but I'm not sure if that's doable. Any ideas on where to go from here?
Upvotes: 0
Views: 467
Reputation: 316
Your response needs to include the opening tag for Number...
<?xml version=”1.0″ encoding=”UTF-8″?>
<Response>
<Dial>
<Number>
*digits*
</Number>
</Dial>
</Response>
https://www.twilio.com/docs/api/twiml/number
To connect the original Say/Gather response to the generated response, you need to specify a callback action, while I think you may be able to specify an XML file (making sure to set the method to GET instead of the default POST), but I don't believe xml has the ability to use a passed parameter. You need to use php or something that can be passed the digits (with PHP it's like this):
<?php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<Response><Dial><Number>$_REQUEST['Digits']</Number></Dial></Response>";
?>
https://www.twilio.com/docs/api/twiml/gather
Upvotes: 1
Reputation: 3680
The digits that were pressed are sent in a POST request to the action of the Gather tag.
So:
<Gather action="/someotherpage.aspx">....</Gather>
On the someotherpage.aspx
the Request.Form["Digits"] will have the value they entered.
Upvotes: 0