【问题标题】:Using Plivo, how can forward an unanswered call to voicemail?使用 Plivo,如何将未接来电转接到语音信箱?
【发布时间】:2014-04-06 00:22:17
【问题描述】:

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

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

谢谢!

【问题讨论】:

    标签: ruby sinatra plivo


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 2014-07-14
      相关资源
      最近更新 更多