使用Plivo,如何将未应答的呼叫转发到语音邮件


如果

呼叫无人应答,我想将呼叫重定向到语音邮件。代码为:

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 子句,基本上是说:如果呼叫应答结束于挂断,如果不去语音信箱?我该怎么做?

谢谢!

已解决。以下人员接收呼叫,并在所有情况下转接到语音邮件 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

我希望这对其他人有所帮助,我花了大量的实验才能到达那里!

最新更新