Asterisk:在 h 扩展中使用 Queue()

Asterisk:在 h 扩展中使用 Queue()

我试图让用户能够录制消息、挂断电话并继续通话、拨打队列并播放录音。

我已经完成了大部分工作,但现在当我拨打Queue()h 分机时,它会立即挂断(队列成员确实会在 1ms 左右接到电话)。虽然我正在使用选项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选项?

答案1

我实际上无法找到解决所有遇到的问题的方法,我最终的解决方案是使用 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进入队列,一旦呼叫接通,它就会运行后队列子程序,playback-recorded-message播放一条消息

我相信肯定有更好的、更少黑客的解决方案,但以我对 Asterisk 的理解程度,这是我能想到的最好的解决方案。希望它能对某人有所帮助

相关内容