Friday, February 1, 2019

Asterisk Code Bits


Asterisk TIMEOUT command
Configure call duration
[from-pstn-limited]
exten => _.,1,Set(TIMEOUT(absolute)=3600)
exten => _.,n,Goto(from-pstn,${EXTEN},1)

Set context in trunk peer details with 
context=from-pstn-limited

Asterisk GotoIF command
comparison between two variables TEST and TEST2

n,Set(TEST=101)

n,Set(TEST2=102)
n,GotoIf($[${TEST} = ${TEST2}]?10:20)
exten => 1,10,NoOp(&&&& match
exten => 1,11,Hangup()
exten => 1,20,NoOp(&&&&&&& mismatch)
exten => 1,21,HanguP()

Asterisk LOOP COUNTER code

exten => s,n,Set(Attempts=1)

exten => s,n,Set(Attempts=${MATH(${Attempts}+1,i)})
exten => s,n,ExecIf($["${Attempts}"="4"]?HANGUP())
exten => s,n,Playback(if-this-is-correct-press)
exten => s,n,SayDigits(1)
exten => s,n,Read(digi,,1)
exten => s,n,ExecIf($["${digi}"="1"]?goto(writevalue))
exten => s,n(writevalue),NoOp(Caller pressed 1)


Some LEN and EXECIF examples (MORE ExecIF examples here)
exten => 001,1, Answer ()
same => n, Noop ($ {CALLERID (num)})
same => n, Set (ARG1 = $ {CALLERID (num)})
same => n, Noop (len of $ {LEN ($ {ARG1})})
same => n, ExecIf ($ [$ {LEN ($ {ARG1})} = 11]? Set (CALLERID (num) = $ {ARG1: 0: 7} $ {RAND (1000,9999)}))
same => n, ExecIf ($ [$ {LEN ($ {ARG1})}> 11]? Set (CALLERID (num) = $ {ARG1: 0: 7}) )



exten => 123,1,Set(foo=${LEN(${test})})


No comments:

Post a Comment

Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.