问题描述
我正在尝试在整个通话期间重复要循环播放的 SAY 消息.
I am trying to repeat a SAY message to be played in loop for the entire call duration.
目前有效.我如何才能播放消息,暂停 2 秒.
Currently it works. How can I get the message to be played, with a PAUSE of 2 seconds.
这是一个示例代码:
<Response>
<Gather>
<Say voice="woman" loop="0">This is my SAY message, which is repeating. How to repeat this with a pause of 2 seconds.</Say>
<Pause length="5"></Pause>
</Gather>
</Response>
twilio 文档提到在 SAY 之外使用它.
The twilio documentation mention to use it outside a SAY.
https://www.twilio.com/docs/api/twiml/say"如果你想插入一个长停顿,请尝试使用 动词.
应该放在
之外code> 标签,而不是嵌套在其中."
https://www.twilio.com/docs/api/twiml/say"If you want to insert a long pause, try using the <Pause>
verb. <Pause>
should be placed outside <Say>
tags, not nested inside them."
但在当前的实现中,永远不会达到这个暂停.
But with the current implementation, this pause will be never reached.
有人可以指导我吗.
尝试使用重定向来重复一条消息,但一旦接听,电话就会在 2 秒内掉线.添加暂停不是这样,重定向是,如果这有什么问题,有人可以指导我吗?
Trying to use redirect to repeat a message but call gets dropped within 2 seconds once answered. Adding pause is not casuing this, the redirect is, Can someone guide me if there is anything wrong in this?
public TwiMLResponse myMethod(){
TwiMLResponse twimlResponse = new TwiMLResponse();
Gather gather = new Gather();
gather.setFinishOnKey("any digit");
gather.setNumDigits(1);
gather.setAction("myendpoint");
Say say = new Say("This message needs to repeat with a pause");
//Pause pause = new Pause();
//pause.setLength(2);
Redirect redirect = new Redirect("myendpoint");
try {
gather.append(say);
//gather.append(pause);
gather.append(redirect);
twimlResponse.append(gather);
} catch (TwiMLException e) {
LOGGER.warn("exception " + e);
}
return twimlResponse;
}
推荐答案
Twilio 开发人员布道者在这里.
Twilio developer evangelist here.
您实际上可以使用 动词在 Twilio 中循环一个
和一个
.你可以这样使用它:
You can actually use the <Redirect>
verb in Twilio to loop a <Say>
and a <Pause>
. You could use it like this:
/gather.xml
/gather.xml
<Response>
<Gather>
<Say voice="woman">This is my SAY message, which is repeating. How to repeat this with a pause of 2 seconds.</Say>
<Pause length="2"></Pause>
</Gather>
<Redirect>/gather.xml</Redirect>
</Response>
如果这有帮助,请告诉我.
Let me know if this helps.
这篇关于Twilio 如何在 SAY 循环中添加暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!