[英]can I send DTMF variable in Twilio IVR as in <sendDTMF digits="variable"/> format?
I am trying to send a DTMF Numeric value in Twilio with the code below but it seems that the string interpolation is not working:我正在尝试使用以下代码在 Twilio 中发送一个 DTMF 数字值,但似乎字符串插值不起作用:
<sendDTMF digits="variable"/>
I was able to hard code it to <sendDTMF digits="123456"/>
and it worked for testing.我能够将它硬编码为
<sendDTMF digits="123456"/>
并且它可以用于测试。
I've tried the following but it's also not working:我尝试了以下但它也不起作用:
<sendDTMF digits="{variable}"/>
<sendDTMF digits=$"{variable}"/>
Twilio developer evangelist here. Twilio 开发者布道师在这里。
As Alan has said in a comment, there are 3 ways to send DTMF over a phone call.正如艾伦在评论中所说,有 3 种方法可以通过电话发送 DTMF。 I'll go into each of them in a bit of depth here.
我将 go 在这里稍微深入地介绍它们中的每一个。
Firstly, while on a call you can use the <Play>
TwiML element to send DTMF.首先,在通话中您可以使用
<Play>
TwiML 元素发送 DTMF。 To do so, you use the digits
attribute , like this:为此,您可以使用
digits
属性,如下所示:
<Response>
<Play digits="1234"/><Play>
</Response>
You can add spaces between the numbers using w
, each w
adds 0.5 seconds gap between other digits.您可以使用
w
在数字之间添加空格,每个w
在其他数字之间增加 0.5 秒的间隔。
Also, on a call, when making dialling on to a new number using the <Number>
element you can send DTMF tones that will be played when the call is picked up before connecting the dialler using the sendDigits
attribute.此外,在通话中,当使用
<Number>
元素拨打新号码时,您可以发送 DTMF 音调,在使用sendDigits
属性连接拨号器之前接听电话时将播放该音调。 That looks like this:看起来像这样:
<Response>
<Dial>
<Number sendDigits="1234"/>NUMBER_TO_DIAL</Number>
</Dial>
</Response>
Using <Number>
to dial and send digits is useful when you have an incoming call that you are connecting to another number.当您有一个要连接到另一个号码的来电时,使用
<Number>
拨号和发送数字很有用。 When you are making an outbound call you can also pass the SendDigits
parameter along with the rest of the call parameters.当您进行出站呼叫时,您还可以将
SendDigits
参数与呼叫参数的 rest 一起传递。 Like with <Number>
, the digits will be played down the call and then it will connect.与
<Number>
一样,数字将在通话中播放,然后连接。
That looks like this:看起来像这样:
curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Calls.json \
--data-urlencode "Twiml=<Response><Say>Ahoy there</Say></Response>" \
--data-urlencode "To=+15558675310" \
--data-urlencode "From=+15552223214" \
--data-urlencode "SendDigits=1234" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.