Asterisk

星號:在 h 擴展中使用 Queue()

  • April 5, 2020

我試圖讓使用者能夠錄製消息、掛斷電話、繼續通話、撥打隊列並播放錄音。

我已經完成了大部分工作,但是現在當我撥打Queue()h 分機時,它會立即掛斷(隊列成員確實接到了大約 1 毫秒的電話)。雖然我正在使用選項c

我的撥號方案(為簡潔起見)

[standard-gn-helpdesk-corona-afterhours]
; Hangup Extension
exten => h,1, NoOp(hangup standard-gn-helpdesk-corona-afterhours)
same => n, Gosub(sub-queue-gn-afterhours,s,1)
same => n, Return()

exten => s,1, NoOp(standard-gn-helpdesk-corona-afterhours)
same => n, Record(gn_ah_recording%d:ulaw)
same => n, Hangup()
; Callee has hungup by this point. `h` should be executed

[playback-recorded-message]
exten => s,1, NoOp(playback-recorded-message)
same => n, Playback(${RECORDED_FILE})

[sub-queue-gn-afterhours]
exten => s,1,NoOp(sub-queue-gn-afterhours)
; Has the `c` option which allows the queue to continue when callee hangs
same => n,Queue(GNAfterHours1,tkc,,,540,,,playback-recorded-message)
same => n,Return()

任何的意見都將會有幫助。我會被迫使用Dial()F選項嗎?

我實際上無法解決遇到的所有問題,我的最終解決方案最終成為使用 AGI 使用本地頻道發起新呼叫的一種變通方法。我的撥號計劃最終看起來像這樣:

[standard-gn-helpdesk-corona-afterhours]
; Hangup Extension
exten => h,1, NoOp(hangup standard-gn-helpdesk-corona-afterhours)
same => n, AGI(dial-playback-recorded-messages.php)
same => n, Hangup()

exten => s,1, NoOp(standard-gn-helpdesk-corona-afterhours)
same => n, Record(gn_ah_recording%d:wav)
same => n, Hangup()
; Callee has hungup by this point. `h` should be executed

[playback-recorded-message]
exten => s,1, NoOp(playback-recorded-message)
same => n, Playback(${RECORDED_FILE})

[sub-queue-gn-afterhours]
exten => s,1,NoOp(sub-queue-gn-afterhours)
; Total hack! This is bad practice, but I don't have shared func and I couldn't find another way to keep this variable in scope when using Queue -> Sub
same => n, Set(GLOBAL(RECORDED_FILE)=${RECORDED_FILE})
same => n,Queue(GNAfterHours1,tk,,,540,,,playback-recorded-message)
same => n,Return()

[from-internal-default]
; Outbound dial for AH
exten => 8745111,1, Answer()
same => n, Gosub(sub-queue-gn-afterhours,s,1)
same => n, Hangup()

; Inbound dial for AH
exten => 8745112,1, Answer()
same => n, Wait(3600)
same => n, Hangup()

我的 AGI 腳本看起來像這樣(為簡單起見減少了)

<?php
$recordingFile = $agi->get_variable("RECORDED_FILE", true);
$hasAh = (string) $agi->get_variable("HAS_AFTERHOURS", true); 

$originateMsg = new OriginateAction('local/8745112@from-internal-default');
$originateMsg->setContext('from-internal-default');
$originateMsg->setPriority('1');
$originateMsg->setExtension('8745111');
$originateMsg->setAsync(true);
$originateMsg->setTimeout(19000);
$originateMsg->setVariable('RECORDED_FILE', $recordingFile);
$originateMsg->setVariable('HAS_AFTERHOURS', $hasAh);
$response = $pamiClient->send($originateMsg);

這個怎麼運作:

  1. 來電者進來並記錄消息
  2. 呼叫掛斷並執行 AGI 腳本,該腳本在本地通道8745112和撥打本地分機之間發起新呼叫8745111
  3. 擴展8745112只是等待保持連接打開
  4. 通道8745111移動到隊列中,一旦連接了呼叫,它就會執行 post queue subplayback-recorded-message來播放消息

我相信有一個更好、更簡單的解決方案,但以我對 Asterisk 的理解程度,這是我能想到的最好的解決方案。希望它可以幫助某人

引用自:https://serverfault.com/questions/1010670