I am building a web app using ruby and the twilio api that allows you to call a twilio number and record a voice recording.
This is the method that gets called to record your voice:
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
How do I add in "easter egg" function such as "skip the Say messages" or even, run a complete different method depending on what Digits the user hits. I tried adding the following if
statement right after my response.Record
call, and it does work, although it only works if the user hits *
after the Recording starts and I want it to work starting from the moment the call starts.
if userResponse['Digits'] == "*"
getFeed()
end
I also tried the following:
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
but this way nothing within the until
loop runs at all.
How do I achieve adding a response.Gather
that listens to whatever the user types in at any time during the call?