【发布时间】:2014-09-04 18:55:40
【问题描述】:
我正在使用 ruby 和 twilio api 构建一个网络应用程序,它允许您拨打 twilio 号码并录制语音记录。
这是被调用来录制你的声音的方法:
def getRecord()
Twilio::TwiML::Response.new do |response|
// userResponse = response.Gather --> does this Gather anything someone types at anytime?
response.Say "Hello"
response.Say "Record your message.", :voice => 'woman'
response.Record :maxLength => '5', :trim => "trim-silence", :playBeep => "false", :action => '/feed', :method => 'get'
end.text
end
如何添加“复活节彩蛋”功能,例如“跳过说消息”,甚至根据用户点击的数字运行完全不同的方法。我尝试在我的response.Record 呼叫之后立即添加以下if 语句,它确实有效,尽管它仅在用户在录制开始后点击* 时才有效,我希望它从呼叫开始的那一刻开始工作.
if userResponse['Digits'] == "*"
getFeed()
end
我还尝试了以下方法:
def getRecord()
Twilio::TwiML::Response.new do |response|
// userResponse = response.Gather --> does this Gather anything someone types at anytime?
until userResponse == '*' do
response.Say "Hello"
response.Say "Record your message.", :voice => 'woman'
response.Record :maxLength => '5', :trim => "trim-silence", :playBeep => "false", :action => '/feed', :method => 'get'
end
if userResponse == '*'
getFeed()
end
end.text
end
但这样until 循环中的任何内容都不会运行。
如何添加一个response.Gather 来监听用户在通话期间随时输入的任何内容?
【问题讨论】:
标签: ruby twilio twilio-twiml