我正在使用 ruby 和 twilio api 构建一个 Web 应用程序,它允许您拨打 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
如何添加“复活节彩蛋”功能,例如“跳过说消息”,甚至根据用户点击的数字运行完全不同的方法。我尝试在通话后立即添加以下if
语句response.Record
,它确实有效,尽管它仅在用户*
在录音开始后点击时才有效,并且我希望它从通话开始的那一刻开始工作。
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
在通话期间随时添加监听用户输入的内容?