如果无人接听,我想将呼叫重定向到语音信箱。代码是:
get '/inbound' do
CALLER_ID = 'caller_number'
to = 'dest_number'
r = Response.new()
r.addSpeak('Thanks for calling acme, if someone does not answer within 20 seconds you will be directed to voicemail')
r.addDial({'callerId' => CALLER_ID, 'timeout' => '20'}).addNumber(to)
r.addSpeak("The number you're trying is not reachable at the moment. You are being redirected to the voice mail")
r.addDial('action' => 'http://frozen-lake-7349.herokuapp.com/voicemail', 'method' => 'GET')
content_type 'text/xml'
r.to_xml()
end
这部分有效,因为它确实转发到语音邮件 URL 并进行了录音,但是如果呼叫被接听,当响应方挂断时,流程继续,呼叫者无论如何都会被路由到语音邮件,当然,现在没有必要,因为各方已经发言。
那么,是否应该在某个地方有一个 if 子句,它基本上说:如果呼叫在挂断时结束,如果不转到语音信箱?我怎样才能做到这一点?
谢谢!