1

如果无人接听,我想将呼叫重定向到语音信箱。代码是:

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 子句,它基本上说:如果呼叫在挂断时结束,如果不转到语音信箱?我怎样才能做到这一点?

谢谢!

4

1 回答 1

3

解决了。以下接收呼叫,并在所有情况下转移到语音邮件 URL(如果呼叫无人应答,则观察超时)

get '/inbound' do
#from = params[:From]
CALLER_ID = 'from caller'
#to = lookup in DB routing
to = 'destination_number'
r = Response.new()
r.addSpeak('Thanks for calling acme, you will be routed to voicemail in 25 seconds if he does not answer!')
r.addDial({'callerId' => CALLER_ID, 'action' => 'http://frozen-lake-7349.herokuapp.com/voicemail', 'method' => 'GET', 'timeout' => '25'}).addNumber(to)
content_type 'text/xml'
    r.to_xml()
end

然后 if 子句进入语音邮件部分,如下所示:

get '/voicemail' do
r = Response.new()
if params['CallStatus'] != 'completed'
r.addSpeak('Please leave a message and press the hash sign when done.')
r.addRecord({'method' => 'GET', 'maxLength' => '60', 'finishOnKey' => '#', 'playBeep' => 'true'}) 
r.addHangup()
else
r.addHangup()
end
content_type 'text/xml'
    r.to_xml()
end

我希望这对其他人有所帮助,我花了很多实验才到达那里!

于 2014-04-07T08:42:19.917 回答