Application
Answer(),Playback()和Hangup()应用
Answer()应用于接听正在响铃通道,它不需要任何参数.
Playback()应用在通道上播放事先录制好的语音文件.指定一个文件名(不带扩展名),可以使用绝对路径与相对路径.
Hangup()应用在于挂断一个正在活动的通道.
Background(),Goto()应用
Background()它也播放事先录制好的语音文件,但它等待按键,然后执行对应extension.
防止Background()后超出按键范围,使用i来解决问题.
防止Background长时间没有选择,使用t来决解问题.
Goto()应用使得在拨号方案的不同部分有序的转移非常容易.
Goto()应用有三个参量分别是context,extension,和priority.即Goto(context,extension,priority)
Dial()应用
Dial()有4个参量,
第一个是:呼叫的被叫地(传输技术/远地资源)如:SIP/50000或Zap/1.可以同时拨打多个通道如:
exten => 601,1,Dial(Zap/1&SIP/50000&IAX/60000) |
exten => 601,1,Dial(SIP/50000,30,Ttwr) |
exten => 601,1,Dial(SIP/60000@asterisk.voip.org)exten => 602,1,Dial(Zap/1/5732381) |
exten => 601,1,Dial(SIP/60000,,T)或exten => 601,1,Dial(SIP/60000) |
[test] exten => s,1,Answer() exten => s,2,Background(enter-ext-of-person) exten => 601,1,Dial(Zap/1,30,Ttrw) exten => 601,2,Playback(vm-nobodyavail) exten => 601,3,Hangup() exten => 601,102,Playback(tt-allbusy) exten => 601,103,Hangup() exten => 602,1,Dial(SIP/50000,30,Ttrw) exten => 602,2,Playback(vm-nobodyavail) exten => 602,3,Hangup() exten => 602,102,Playback(tt-allbusy) exten => 602,103,Hangup( ) exten => i,1,Playback(pbx-invalid) exten => i,2,Goto(test,s,1) exten => t,1,Playback(vm-goodbye) exten => t,2,Hangup() |
[globals]80000=Zap/1或[internal]exten => 123,1,SetGlobalVar(80000=Zap/1) |
exten => 601,1,Set(80000=Zap/1) |
[globals]PSTN=Zap/1TEST=SIP/80000 [test]exten => s,1,Answer()exten => s,2,Background(enter-ext-of-person)exten => 101,1,Dial(${PSTN},10)exten => 101,2,Playback(vm-nobodyavail)exten => 101,3,Hangup()exten => 101,102,Playback(tt-allbusy)exten => 101,103,Hangup()exten => 102,1,Dial(${TEST},10)exten => 102,2,Playback(vm-nobodyavail)exten => 102,3,Hangup()exten => 102,102,Playback(tt-allbusy)exten => 102,103,Hangup()exten => i,1,Playback(pbx-invalid)exten => i,2,Goto(incoming,s,1)exten => t,1,Playback(vm-goodbye)exten => t,2,Hangup() [default]exten => 101,1,Dial(${PSTN},,r)exten => 102,1,Dial(${TEST},,r) |
X:匹配 0-9 的任何数字;Z:匹配 1-9 的任何数字;N:匹配 2-9 的任何数字;.(句号)通配符,匹配一个或多个字符;[15-7]:匹配1,5,6,7; |
exten => _9XXXXXXX,1,SayDigits(${EXTEN});SayDigits()应用会把所拨的8位extension读出来 exten => _9XXXXXXX,1,SayDigits(${EXTEN:1});只读出来后7位数,其中"1"表示不拨前面1位数 exten => _9XXXXXXX,1,SayDigits(${EXTEN:-1});只读出来最后1位,其中"1"表示只拨出最后1位数 |
---本地去话拨号---[outbound-local]ignorepat => 9exten => _9NXXXXXX,1,Dial(Zap/1/${EXTEN:1})exten => _9NXXXXXX,2,Congestion()exten => _9NXXXXXX,102,Congestion()---再加入紧急电话拨号---exten => 9119,1,Dial(Zap/1/119)exten => 119,1,Dial(Zap/1/119)exten => 9110,1,Dial(Zap/1/110)exten => 110,1,Dial(Zap/1/110)---长途电话拨号---[outbound-long]exten => _90NXXNXXXXXX,1,Dial(Zap/1/${EXTEN:1})exten => _90NXXNXXXXXX,2,Congestion()exten => _90NXXNXXXXXX,102,Congestion() |
[internal]include => outbound-localinclude => outbound-longexten => _80XXX,1,Dial(SIP/${EXTEN},30,r)exten => _80XXX,2,Playback(vm-nobodyavail)exten => _80XXX,3,Hangup()exten => _80XXX,102,Playback(tt-allbusy)exten => _80XXX,103,Hangup() |
$[expression]$[${COUNT} + 1]$[${COUNT} / 2];引用变量,必须把这个变量名用花括号"{}"括起来,而且在前面加上美元符号"$" 标示出来 |
${FUNCTION_NAME(argument)} |
${FUNCTION_NAME(${FUNCTION_NAME(argument)})} |
exten=>123,1,set(TEST=example) ;赋值example变量给TESTexten=>123,2,saynumber(${LEN(${TEST})}) ;计算出变量TEST长度,并读出长度数结果是:7 |
exten=>s,1,set(TIMEOUT(digit)=30) |