2014-09-04 3 views
-1

나는 루비와 Twilio 번호를 호출하고 음성 녹음을 녹음 할 수있는 twilio API를 사용하여 웹 응용 프로그램을 만들고 있습니다.Twilio Skip Options (ruby)

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 전화 바로 다음에 추가하려고 시도했지만 작동합니다.

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 루프 내에서 이런 식으로 아무것도 전혀 실행 :

if userResponse['Digits'] == "*" 
    getFeed() 
    end 

은 또한 다음과 같은 시도했다.

response.Gather을 추가하는 방법은 무엇입니까? 사용자가 전화하는 동안 언제든지 사용자의 전화를 청취하려면 어떻게해야합니까?

답변

0

저는 Twilio의 개발자 전도자이며 여기서 도와 드릴 수 있다고 생각합니다.

예를 들어 원래의 방법을 촬영, 당신은 다음을 수행 할 수

def getRecord() 
    Twilio::TwiML::Response.new do |response| 
    response.Gather :finishOnKey => '*' 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 
    # Whatever you want to happen when the user presses * 
    getFeed() 
    end.text 
end 

당신이 볼 수 있듯이, 당신은 내 둥지 TwiML는 블록을 수집 할 수 있습니다. 이 경우 Gather는 키를 누를 것입니다. 메시지 나 녹음이 진행되는 동안 사용자가 *를 누르면 Gather 동사의 끝으로 점프하고 Gather 후에 TwiML을 계속 진행합니다.이 경우에는 getFeed 메서드를 호출합니다. 피드 엔드 포인트로 리디렉션하는 것이 좋으며 그 경우 response.Redirect '/feed', :method => 'get'을 사용할 수 있습니다.

도움이 될지 알려주세요.