user3382902
user3382902

Reputation: 33

How to repeat message with twilio

I am trying to build an application with Twilio. My application is Online shopping and as soon as order is placed, call should go to owner with ordering details. Everything is working fine.But the problem is with repeating the message. I want to repeat message on keypress.

For example:<Say> To repeat this message, press # </Say>

How can I achive this in twilio?

My Xml is:

<?xml version="1.0" encoding="utf-8"?>
<Response> 
  <Say voice="alice">
    You received an order.
  </Say>
<Say voice="alice">
    Order Details ........
  </Say>
</Response>

Upvotes: 3

Views: 2411

Answers (1)

xmjw
xmjw

Reputation: 3434

Hi Twilio Evangelist here.

You can achieve this using the <Gather> verb. This allows the caller to enter keytones (DTMF tones) such as #.

The <Gather> verb will make an HTTP request to your application with a Digits parameter indicating if the user pressed a key. For example:

<Response>
  <Gather action="/some-url-on-your-server" timeout="10" numDigits="1">
    <Say>Here is some information, to repeat it press #</Say>
  </Gather>
</Response>

If the user presses #, this will be sent to your application. If they do not press a key, the <Gather> will time out after 10 seconds (default is 5, but you can set this as you like). This time period starts from after the <Say> completes. So in the above example there will be 10 seconds of silence.

For this example, be sure to use numDigits="1", not finishOnKey="#". Because Twilio will strip the # if it's the 'finish' key.

Your response on the action="" part of your application can then either respond with a repeat of the information, or proceed to the next step.

Hope this helps!

Upvotes: 3

Related Questions