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 に答える