Asterisk 将呼叫转移到号码 A,当 A 挂断时,转移到 B

Asterisk forward a call to number A and when A hangs up, forward to B

我的用例很简单:Asterisk是中间人,接到外面的电话转给A,A挂了,我想马上转给B。再做一个 Dial 就够了吗? 你有什么例子吗?

+12345 --- Asterisk------------------ B
              |    when A hangs up call B
              |
              A

如果使用 Dial 应用程序调用 A,您可以使用 'g' 选项,并在第一次 Dial to A 之后调用 B。

根据 Dial 文档:

g - Proceed with dialplan execution at the next priority in the current extension if the destination channel hangs up

在下面的例子中,先拨1001星号呼叫SIP/A。如果 A 挂断,asterisk 呼叫 B。最后一次呼叫中的选项 'g' 不是必需的。我离开它是为了将来能够修改表盘,或者以防万一我想增加链条。请注意最后的挂断,如果没有选项 'g' 则不是绝对必要的,但即使没有 'g' 选项也很方便(如果你设置超时并且你想在超时时播放声音).

exten => 1001, 1, Dial(SIP/A,,gm)
same => n, Dial(SIP/B,,gm)
same => n, Hangup()