2017-02-14 44 views
0

我用call_phone撥打電話,然後當它回答時,我要求用戶「請按一個繼續」。如果他們在超時之前沒有按任何數字。我再問一次,然後說:「我沒有得到任何迴應,請按下繼續。」說動詞不執行裏面收集動詞與twilio和鐵軌

call_phone()工作並在用戶應答時重定向到communications_digits_path。我聽到「請按一個繼續」,如果我按電話鍵盤上的一個。該呼叫重定向到communications_menu_path。

問題是,如果我不按任何電話鍵,而不是播放「我沒有得到任何迴應,請按下繼續。」,電話掛斷。任何想法我做錯了什麼?

def call_phone(phone_number) 
    @client = Twilio::REST::Client.new(
    Rails.application.secrets.twilio_voice_sid, 
    Rails.application.secrets.twilio_token 
) 
    @call = @client.account.calls.create(
    from: Rails.application.secrets.twilio_voice_number, 
    to: phone_number, 
    url: communications_digits_path, 
) 
end 

def digits 
    twiml_response = Twilio::TwiML::Response.new do |r| 
    r.Say "Please press one to continue", voice: 'alice', language: 'an-AU' 
    r.Gather numDigits: '1', action: communications_menu_path do |g| 
     g.say "I didn't get any response. Please press one to continue." 
    end 
    end 
    render :xml => twiml_response.to_xml 
end 

回答

0

Twilio開發者傳道這裏。

我認爲問題在於你的第二個<Say>的小寫「s」。

但是總的來說,我們可以通過一些更改使其更穩健一些。首先,如果用戶在第一條消息仍在播放時按下一個,則不會發生任何事情,因爲它不在<Gather>內。其次,我們可以在兩條消息之間<Pause>給予用戶一個機會。

嘗試類似:

def digits 
    twiml_response = Twilio::TwiML::Response.new do |r| 
    r.Gather numDigits: '1', action: communications_menu_path do |g| 
     g.Say "Please press one to continue", voice: 'alice', language: 'an-AU' 
     g.Pause length: 5 
     g.Say "I didn't get any response. Please press one to continue.", voice: 'alice', language: 'an-AU' 
    end 
    end 
    render :xml => twiml_response.to_xml 
end 

讓我知道是否有幫助。

+0

這正是我一直在尋找的。謝謝菲爾 – RamJet