Asterisk GoSub() function not working for me - asterisk
I am trying to make calls between extensions 101 and 102 and is NOT going through. I have the following extensions.conf file
[general]
autofallthrough=no
priorityjumping=yes
static=yes
writeprotect=no
clearglobalvars=yes
[default]
exten => .,1,Hangup()
[inbound-schedule]
; #_#_# Phone Number #_#_#
exten => 7867086699,1,Answer
exten => 7867086699,n,NoOp(Office-ANI-${EXTEN})
exten => 7867086699,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)})
exten => 7867086699,n,MixMonitor(ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav)
exten => 7867086699,n,Goto(schedule,${EXTEN},1)
exten => .,1,Hangup()
[schedule]
exten => _NXXNXXXXXX,1,NoOp(Time-of-Day-Routing)
exten => _NXXNXXXXXX,n,GotoIfTime(8:58-17:02,mon-fri,*,*?inbound,${EXTEN},1)
exten => _NXXNXXXXXX,n,Goto(inbound-closed,${EXTEN},1)
[inbound]
exten => _NXXNXXXXXX,1,NoOp(Office-Open)
exten => _NXXNXXXXXX,n,Set(NUMINVALID=1)
exten => _NXXNXXXXXX,n,Set(TIMEOUT(digit)=3) ; max wait in-between digits seconds
exten => _NXXNXXXXXX,n,Set(TIMEOUT(response)=3) ; max wait for digit entry seconds
exten => _NXXNXXXXXX,n,Ringing
exten => _NXXNXXXXXX,n(menu),Wait(1)
exten => _NXXNXXXXXX,n,Background(custom/open-recording)
exten => _NXXNXXXXXX,n,Wait(3)
exten => _NXXNXXXXXX,n,Background(custom/open-recording)
exten => _NXXNXXXXXX,n,Wait(3)
exten => _NXXNXXXXXX,n,Dial(SIP/101,18)
exten => _NXXNXXXXXX,n,Voicemail(100#default,su)
exten => 0,1,NoOp(Office-Open-Press-Zero)
exten => 0,n,Voicemail(100#default,su)
exten => 2,1,NoOp(Operator-Directory)
exten => 2,n,Directory(default,vm-operator,f)
exten => 200,1,NoOp(External-Voicemail-Dial-From-${CALLERID(num)})
exten => 200,n,Playback(vm-dialout)
exten => 200,n,Wait(1)
exten => 200,n,VoiceMailMain()
exten => _1XX,1,Macro(local-followme,${EXTEN})
exten => t,1,Playback(option-is-invalid)
exten => t,n,Hangup()
exten => i,1,Set(NUMINVALID=$[${NUMINVALID}+1]})
exten => i,n,Playback(option-is-invalid)
exten => i,n,Gotoif($["${NUMINVALID}" < "4"]?:10)
exten => i,n,Goto(_NXXNXXXXXX,menu)
exten => i,10,Playback(vm-goodbye)
exten => i,n,Hangup()
[inbound-closed]
exten => _NXXNXXXXXX,1,NoOp(Office-Closed)
exten => _NXXNXXXXXX,n,Set(NUMINVALID=1)
exten => _NXXNXXXXXX,n,Set(TIMEOUT(digit)=3)
exten => _NXXNXXXXXX,n,Set(TIMEOUT(response)=3)
exten => _NXXNXXXXXX,n,Ringing
exten => _NXXNXXXXXX,n(menu),Wait(1)
exten => _NXXNXXXXXX,n,Background(custom/closed-recording)
exten => _NXXNXXXXXX,n,Wait(3)
exten => _NXXNXXXXXX,n,Background(custom/closed-recording)
exten => _NXXNXXXXXX,n,Wait(3)
exten => _NXXNXXXXXX,n,Dial(SIP/101,18)
exten => _NXXNXXXXXX,n,Voicemail(100#default,su)
exten => 0,1,NoOp(Office-Open-Press-Zero)
exten => 0,n,Voicemail(100#default,su)
exten => 2,1,NoOp(Operator-Directory)
exten => 2,n,Directory(default,vm-operator,f)
exten => 200,1,NoOp(External-Voicemail-Dial-From-${CALLERID(num)})
exten => 200,n,Playback(vm-dialout)
exten => 200,n,Wait(1)
exten => 200,n,VoiceMailMain()
exten => _1XX,1,Macro(local-followme,${EXTEN})
exten => t,1,Playback(option-is-invalid)
exten => t,n,Hangup()
exten => i,1,Set(NUMINVALID=$[${NUMINVALID}+1]})
exten => i,n,Playback(option-is-invalid)
exten => i,n,Gotoif($["${NUMINVALID}" < "4"]?:10)
exten => i,n,Goto(_NXXNXXXXXX,menu)
exten => i,10,Playback(vm-goodbye)
exten => i,n,Hangup()
[outbound]
exten => _NXXNXXXXXX,1,Dial(SIP/${EXTEN}#voip-outbound,120,trwW)
exten => _NXXNXXXXXX,n,Hangup()
exten => .,1,Playback(invalid)
exten => .,n,Hangup()
[internal]
; #_#_#_#_#_#_#_#_# INTERNAL MAIN CONTEXT #_#_#_#_#_#_#_#_#_#
; Extension to Extension Dialing
exten => _1XX,1,Macro(local-followme,${EXTEN})
; Call Pickup
exten => _*971XX,1,SET(GLOBAL(PICKUPMARK)=${EXTEN:2})
exten => _*971XX,n,Pickup(${EXTEN:2}#PICKUPMARK)
; Voicemail Access
exten => 1000,1,VoiceMailMain(${CALLERID(num)}#default)
exten => 2000,1,VoiceMailMain()
; Outbound Dialing
exten => _NXXXXXX,1,Answer
exten => _NXXXXXX,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)})
exten => _NXXXXXX,n,MixMonitor(ob_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav)
exten => _NXXXXXX,n,Set(CALLERID(num)=7867086699)
exten => _NXXXXXX,n,Goto(outbound,310${EXTEN},1)
exten => _NXXNXXXXXX,1,Answer
exten => _NXXNXXXXXX,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)})
exten => _NXXNXXXXXX,n,MixMonitor(ob_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav)
exten => _NXXNXXXXXX,n,Set(CALLERID(num)=7867086699)
exten => _NXXNXXXXXX,n,Goto(outbound,${EXTEN},1)
exten => _1NXXNXXXXXX,1,Answer
exten => _1NXXNXXXXXX,n,Set(CDR(userfield)=ib_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)})
exten => _1NXXNXXXXXX,n,MixMonitor(ob_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${EXTEN}_${CALLERID(num)}.wav)
exten => _1NXXNXXXXXX,n,Set(CALLERID(num)=7867086699)
exten => _1NXXNXXXXXX,n,Goto(outbound,${EXTEN:1},1)
exten => t,1,Playback(invalid)
exten => t,n,Hangup()
exten => i,1,Playback(invalid)
exten => i,n,Hangup()
exten => .,1,Playback(invalid)
exten => .,n,Hangup()
[macro-local-followme]
exten => s,1,GotoIf($[${DB_EXISTS(followme/${ARG1})}=0]?nofollow)
exten => s,n,GotoIf($[${DB_RESULT:0:1}=0]?nofollow:follow)
exten => s,n(follow),Dial(SIP/${ARG1},20)
exten => s,n,Followme(${ARG1},n) ; Removed sa so no name recording
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(nofollow),Dial(SIP/${ARG1},20)
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(${ARG1},u) ; If unavailable, send to voicemail
exten => s-BUSY,1,Voicemail(${ARG1},u) ; I changed b to u. If busy, send to voicemail w/ busy ann
exten => _s-.,1,Goto(s-NOANSWER,1)
[outbound-follow-me]
exten => _NXXNXXXXXX,1,NoOp(follow-me-activated-${EXTEN})
exten => _NXXNXXXXXX,n,Set(CALLERID(num)=${IF($[ ${LEN(${CALLERID(num)})} = 3]?7867086699:${CALLERID(num)})})
exten => _NXXNXXXXXX,n,Goto(outbound,${EXTEN},1)
exten => _1NXXNXXXXXX,1,NoOp(follow-me-activated-${EXTEN})
exten => _1NXXNXXXXXX,n,Set(CALLERID(num)=${IF($[ ${LEN(${CALLERID(num)})} = 3]?7867086699:${CALLERID(num)})})
exten => _1NXXNXXXXXX,n,Goto(outbound,${EXTEN:1},1)
exten => _1XX,1,Dial(SIP/${EXTEN},120,t)
exten => _1XX,n,Hangup()
[vm-operator]
exten => o,1,NoOp(operator-zero-out)
exten => o,n,Goto(vm-zero-menu,s,1)
; Direct Extension Dialing
exten => _1XX,1,Macro(local-followme,${EXTEN})
[vm-zero-menu]
exten => s,1,NoOp(operator-asterisk-out)
exten => s,n,Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=3)
exten => s,n,Background(custom/vm-operator-recording)
exten => s,n,Wait(3)
exten => s,n,Voicemail(100#default,su)
exten => 0,1,Voicemail(100#default,su)
exten => 1,1,NoOp(Operator-Directory)
exten => 1,n,Directory(default,vm-operator,f)
exten => 2,1,Voicemail(100#default,su)
exten => 3,1,Voicemail(100#default,su)
exten => 4,1,Voicemail(100#default,su)
exten => 5,1,Voicemail(100#default,su)
exten => 6,1,Voicemail(100#default,su)
exten => 7,1,Voicemail(100#default,su)
exten => 8,1,Voicemail(100#default,su)
exten => 9,1,Voicemail(100#default,su)
; Direct Extension Dialing
exten => _1XX,1,Macro(local-followme,${EXTEN})
exten => t,1,Playback(invalid)
exten => t,n,Hangup()
exten => i,1,Playback(invalid)
exten => i,n,Hangup()
exten => .,1,Playback(invalid)
exten => .,n,Hangup()
I got the following error:
Executing [102#internal:1] Gosub("SIP/101-00000002", "local-followme,s,1(102)") in new stack
[2021-05-18 20:26:16] ERROR[19823][C-0000000a]: app_stack.c:593 gosub_exec: Attempt to reach a non-existent destination for Gosub: (Context:local-followme, Extension:s, Priority:1)
== Spawn extension (internal, 102, 1) exited non-zero on 'SIP/101-00000002'
== Using SIP RTP CoS mark 5
app_stack is loaded apparently, this is what I have with the command "module show like app_stack" on CLI
app_stack.so - Dialplan subroutines (Gosub, Return, etc 0 - Running - core
I will really appreciate any guidance. Thanks.
Confirm if you are reloading the dialplan module by "dialplan reload" command in Asterisk CLI, it seems like what is being executed in the call is GoSub instead of Macro. You can validate dialplan statements loaded in Asterisk by doing "dialplan show" or "dialplan show context-name"
Please, avoid using Macro application, you should use GoSub application instead, Macro is considered deprecated.
Here's a Gosub example:
[internal]
exten => _1XX,1,GoSub(local-followme,s,1(${EXTEN}))
[local-followme]
exten => s,1,Verbose(GoSub executing)
same = n,Verbose(Argument 1: ${ARG1})
same = n,Return()
Related
IVR Asterisk Dial Plan goes indefinite for invalid key press
I'm doing Asterisk Dial Plan in extensions.conf. I am creating a simple IVR in which invalid key press by customer should repeat only two times. After that it should disconnect. But here loop goes indefinite. [ivr1] exten => 100,1,Goto(ivr1,s,1) exten => s,1,Set(VOLUME(TX)=20) exten => s,n,Answer(500) same => n(loop),Background(playfile) same => n,WaitExten(10) exten => 1,1,Dial(SIP/ivr_218/xxxx,30,m(waiting-audio)) exten => 1,2,Dial(SIP/ivr_218/xxxx,30,m(waiting-audio)) same => n,Hangup(${ActionID},keypress1) exten => 2,1,Dial(SIP/ivr_218/xxxx,30,m(waiting-audio)) same => n,Hangup(${ActionID},keypress2) exten => i,1,Playback(playfile_for_invalid) same => n,Goto(s,loop) exten => t,1,Playback(playfile_for_noresponse) same => n,Goto(s,loop) exten => n,Hangup()
You can add counter like this, [ivr1] exten => 100,1,Goto(ivr1,s,1) **exten => s,1,Set(Counter = 0)** exten => s,1,Set(VOLUME(TX)=20) exten => s,n,Answer(500) same => n(loop),Background(playfile) same => n,WaitExten(10) exten => 1,1,Dial(SIP/ivr_218/xxxx,30,m(waiting-audio)) exten => 1,2,Dial(SIP/ivr_218/xxxx,30,m(waiting-audio)) same => n,Hangup(${ActionID},keypress1) exten => 2,1,Dial(SIP/ivr_218/xxxx,30,m(waiting-audio)) same => n,Hangup(${ActionID},keypress2) exten => i,1,Playback(playfile_for_invalid) **same => n,Set(Counter=$[${Counter}+1]) same => n,GotoIf($["${Counter}"<"2"]?s,loop) same => n,Hangup()** exten => t,1,Playback(playfile_for_noresponse) same => n,Goto(s,loop) exten => n,Hangup()
How to make incoming call recors on asterisk?
Situation: Analog phone line -> Asterisk with PSTN card -> Central PBX -> exten => _1709,1,Set(CALLERID(name)=City_09) exten => _1709,n,Noop(${CALLERID(name)}) exten => _1709,n,GoTo(incoming-reception,s,1) Next [incoming-reception] include => external-trunk exten => 0027449999,1,GoTo(incoming-reception,s,1) exten => anonymous,1,GoTo(incoming-reception,s,1) ;exten => s,1,GotoIfTime(9:00-18:00|mon-sat|*|*?incoming-reception-work,s,1) exten => s,1,GotoIfTime(9:00-18:00|mon-fri|*|*?incoming-reception-work,s,1) exten => s,n,Answer() exten => s,n,Set(TIMEOUT(digit)=2) exten => s,n,NoOp(${CALLERID(num)}) exten => s,n,Set(CHANNEL(language)=ru) exten => s,n,Wait(2) exten => s,n,Background(day_off_1_welcome) exten => s,n,Background(day_off_2_message) exten => s,n,Voicemail(2001,s,300) exten => 5,1,GoTo(incoming-reception-enoff,s,2) exten => i,1,GoTo(incoming-reception,s,3) exten => h,1,Congestion(10) exten => h,2,HangUp() next [incoming-reception-work] include => external-trunk exten => s,1,Answer() exten => s,n,Set(TIMEOUT(digit)=2) exten => s,n,NoOp(${CALLERID(num)}) exten => s,n,Set(CHANNEL(language)=ru) exten => s,n,Wait(2) exten => s,n,Background(business_hours_1_welcome) exten => s,n,Queue(test,T,,,32) exten => s,n,Queue(test2,T) exten => s,101,Background(business_hours_4_message) exten => s,102,Voicemail(2001,s,300) exten => 5,1,GoTo(incoming-reception-en,s,1) exten => 9,1,Background(business_hours_4_message) exten => 9,2,Voicemail(2001,s,300) exten => i,1,GoTo(incoming-reception-work,s,1) exten => h,1,Congestion(10) exten => h,2,HangUp() How can I make record incoming calls? Asterisk 1.8 (no freepbx, console only)
You could try to use Monitor/StopMonitor dialplan procedures to record incoming calls. Use the following template: same => n,Monitor(wav,''${UNIQUEID},m) same => n,Set(FILEARG="/tmp/asterisk/monitor/${UNIQUEID}.wav") . . same => n,Hangup() exten => h,1,StopMonitor() same => n,System(/usr/local/bin/record-file-to-database --file=${FILEARG}) Check your Asterisk configs for the exact location of Monitor output folder. See also an example here
How to route to different extensions
I am new to asterisk and I would like to do a simple routing job I have configured asterisk to have 3 sip ddi numbers Below sip.conf: [0001] type=peer fromuser=4420XXXX0001 host=X.X.X.X dtmfmode=rfc2833 canreinvite=no insecure=invite context=default [0002] type=peer fromuser=4420XXXX0002 host=X.X.X.X dtmfmode=rfc2833 canreinvite=no insecure=invite context=default [0003] type=peer fromuser=4420XXXX0003 host=X.X.X.X dtmfmode=rfc2833 canreinvite=no insecure=invite context=default At the moment if I make a call I always use the first DDI 4420XXXX0001 which is the first extension number Below extensions.conf [default] ;Outgoing Number 0001 exten => _44.,1,Noop(CALLERID:${CALLERID}) exten => _44.,n,Set(CALLERID(all)="My Name"<+4420XXXX0001>) exten => _44.,n,Dial(SIP/+${EXTEN:2}#0001) exten => _44.,n,Hangup ;Outgoing Number 0002 exten => _44.,1,Noop(CALLERID:${CALLERID}) exten => _44.,n,Set(CALLERID(all)="My Name"<+4420XXXX0002>) exten => _44.,n,Dial(SIP/+${EXTEN:2}#0002) exten => _44.,n,Hangup ;Outgoing Number 0003 exten => _44.,1,Noop(CALLERID:${CALLERID}) exten => _44.,n,Set(CALLERID(all)="My Name"<+4420XXXX0003>) exten => _44.,n,Dial(SIP/+${EXTEN:2}#0003) exten => _44.,n,Hangup How can I route this out in order to use different lines and different caller ids I apologise for the naming conventions I find difficult to explain this Thanks
Please read any asterisk book. This one topic at start of book, really There are alot of posible variant how to balance trunks. For example this one is random balancing of 3 trunks. [gate];начальный контекст exten => _7XXXXXXXXXX,1,Set(num=${EXTEN}) exten => _7XXXXXXXXXX,2,Goto(gate_variants,${RAND(1,6)},1) [gate_variants];все допустимые варианты exten => 1,1,Set(DO=1-2-3) exten => 2,1,Set(DO=1-3-2) exten => 3,1,Set(DO=2-1-3) exten => 4,1,Set(DO=2-3-1) exten => 5,1,Set(DO=3-1-2) exten => 6,1,Set(DO=3-2-1) exten => _[1-6],2,goto(s,1) exten => s,1,Set(i=0); делаем цикл(я это не писал, это у меня стандартная заготовка ;) ) exten => s,n(loop),Set(i=$[ i + 1]) ; смотрим по номеру exten => s,n,Set(do_now=${CUT(DO,-,${i}) ; берем и-тый номер. exten => s,n,GotoIF($[ "${do_now}" == "" ]?end); номера кончилися (( exten => s,n,Dial(IAX2/manager${do_now}/${num},,g) ; звоним exten => s,n,Goto({DIALSTATUS},1); проверяем результат exten => s,n(end),Hangup; больше нет номеров exten => BUSY,1,Goto(s,loop); повторяем exten => CONGESTION,1,Goto(s,loop) exten => FAIL,1,Goto(s,loop) exten => NOANSWER,1,Goto(s,loop) exten => ANSWER,1,Hangup;это не повторям, вроде дозвонилися. exten => ANSWERED,1,Hangup http://asterisk-support.ru/question/13916/dialplan-balansirovka-i-tsikl-mezhdu-trankami/#19951
Send DTMF Digit with dialplan
I have the following dialplan: exten => 224,1,NoOp(IN CALL : ${CALLERID(num)} => ${EXTEN}) exten => 224,n,Dial(${PJSIP_DIAL_CONTACTS(97,97)}) ;exten => 224,n,Wait(3) exten => 224,n,SendDTMF(*11234*,200) exten => 224,n,Wait(3) exten => 224,n,SendDTMF(#*) exten => 224,n,Hangup() When I call the extension 97 and it is connected, it doesnt seem to go next in line SendDTMF. What am I doing wrong? Greetings
For who is looking for something like this without SendDTMF application, you can send DTMF with D option: exten => n, Dial (SIP/97,60,D(1234)) If the DTMF passed are getted on the other side incomplete, use w option to delay 500 milliseconds. Here I'm delaying 1 second exten => n,Dial (SIP/97,60,D(ww1234))
Did you try using macros [macro-send] exten => s,1,SendDTMF(*11234*,200) exten => s,n,Wait(3) exten => s,n,SendDTMF(#*) [yourDialPlan] exten => 224,1,NoOp(IN CALL : ${CALLERID(num)} => ${EXTEN}) exten => 224,n,Dial(${PJSIP_DIAL_CONTACTS(97,97)},,M(send)) exten => 224,n,Hangup()
Asterisk Dialplan preventing dialplan from repeating continuously
I have the following macro in my diaplan which is excuted each time an incoming call comes. Problem is that it is repeating itself indefinitely. I want it to repeat 3 times, if no input from the user, it should say goodbye and quit. Could anyone help me with this please. Thanks [macro-test] ;exten => s,1,Answer() ;exten => s,n,Wait(2) exten => s,1,Set(AGISIGHUP=no) exten => s,n,NoOp(AGISUGHUP: ${AGISIGHUP}) exten => s,n,Set(CALLED=${MACRO_EXTEN}) exten => s,n,Set(CALLER=${CUT(CUT(SIP_HEADER(From),#,1),:,2)}) exten => s,n(action),Set(EXIT=0) exten => s,n,Set(TOKEN="") exten => s,n,Set(INIT="true") exten => s,n,While($[${EXIT}<1]) exten => s,n,Set(EXIT=1) exten => s,n,Agi(agi://${ARG1}/server.agi?caller=${CALLER}&called=${CALLED}&init=${INIT}) exten => s,n,Set(INIT="false") exten => s,n,NoOp(AGISTATUS: ${AGISTATUS}) exten => s,n,GotoIf($["${AGISTATUS}" != "SUCCESS"]?fail:succ) exten => s,n(succ),EndWhile() exten => s,n,Set(INIT="end") exten => s,n,Agi(agi://${ARG1}/server.agi?caller=${CALLER}&called=${CALLED}&init=${INIT}) exten => s,n,Hangup() exten => s,n(fail),Wait(2) exten => s,n,Playback(vm-goodbye) exten => s,n,Hangup() exten => h,1,NoOp(Notify Billing System) exten => h,n,NoOp(Other Tasks) exten => h,n,Hangup()
Simple loop dialplan exten =>s ,1,Set(loop=3) exten =>s,n(loop),Noop(loop start here) exten =>s,n,Noop(do something here) exten =>s,n,Set(loop=$[ ${loop} - 1 ]);decrease loop countr exten =>s,n,GotoIf($[ ${loop} > 0 ]?loop); if still have something, do again
exten => h,n,Hangup() Don't call hangup, when you're already hung up.