It looks like Asterisk is ignoring the label portion so it will start at the first priority of that context.
;extensions_custom.conf
[originate-alpha]
exten => s,1,Noop(Started Originate)
exten => s,n,Answer()
exten => s,n,Wait(5)
exten => s,n,Hangup()
[originate-label]
exten => s,1,Noop(Originate Label Context)
exten => s,n,Noop(This is the second line)
exten => s,n(bazinga),Noop(This is the third line with a label)
exten => s,n,Hangup()
;test2.call
Channel: local/[email protected]
Callerid: Mark <1018>
WaitTime: 5
Context: originate-label
Extension: s
Priority: bazinga
Asterisk log:
;Asterisk ignores the label 'bazinga'
[2023-03-19 06:45:59] WARNING[71138] pbx_spool.c: Invalid priority at line 6 of /var/spool/asterisk/outgoing/test2.call
[2023-03-19 06:45:59] WARNING[71138] pbx_spool.c: Unable to set utime on /var/spool/asterisk/outgoing/test2.call: Operation not permitted
;Asterisk calls the first leg
[2023-03-19 06:45:59] VERBOSE[48493] pbx_spool.c: Attempting call on local/[email protected] for [email protected]:1 (Retry 1)
[2023-03-19 06:45:59] VERBOSE[48493] dial.c: Called [email protected]
[2023-03-19 06:45:59] VERBOSE[48494][C-00000026] pbx.c: Executing [[email protected]:1] NoOp("Local/[email protected];2", "Started Originate") in new stack
[2023-03-19 06:45:59] VERBOSE[48494][C-00000026] pbx.c: Executing [[email protected]:2] Answer("Local/[email protected];2", "") in new stack
[2023-03-19 06:45:59] VERBOSE[48493] dial.c: Local/[email protected];1 answered
;Asterisk calls the second leg, note it will start with the first priority
[2023-03-19 06:45:59] VERBOSE[48493][C-00000027] pbx.c: Executing [[email protected]:1] NoOp("Local/[email protected];1", "Originate Label Context") in new stack
[2023-03-19 06:45:59] VERBOSE[48493][C-00000027] pbx.c: Executing [[email protected]:2] NoOp("Local/[email protected];1", "This is the second line") in new stack
[2023-03-19 06:45:59] VERBOSE[48493][C-00000027] pbx.c: Executing [[email protected]:3] NoOp("Local/[email protected];1", "This is the third line with a label") in new stack
[2023-03-19 06:45:59] VERBOSE[48493][C-00000027] pbx.c: Executing [[email protected]:4] Hangup("Local/[email protected];1", "") in new stack
[2023-03-19 06:45:59] VERBOSE[48493][C-00000027] pbx.c: Spawn extension (originate-label, s, 4) exited non-zero on 'Local/[email protected];1'
[2023-03-19 06:45:59] NOTICE[48493][C-00000027] pbx_spool.c: Call completed to local/[email protected]
[2023-03-19 06:45:59] VERBOSE[48494][C-00000026] pbx.c: Spawn extension (originate-alpha, s, 2) exited non-zero on 'Local/[email protected];2'
However, if you use Goto()
it works fine, I suspect that this is a bug within Asterisk.
This is when using Goto
;extensions_custom.conf
[originate-alpha]
exten => s,1,Noop(Started Originate)
exten => s,n,Answer()
exten => s,n,Wait(5)
exten => s,n,Hangup()
[originate-mid]
exten => s,1,Noop(Originate Mid Context)
exten => s,n,Goto(originate-label,s,${OLABEL})
[originate-label]
exten => s,1,Noop(Originate Label Context)
exten => s,n,Noop(This is the second line)
exten => s,n(bazinga),Noop(This is the third line with a label)
exten => s,n,Hangup()
;test3.call
Channel: local/[email protected]
Callerid: Mark <1018>
WaitTime: 5
Context: originate-mid
Extension: s
Priority: 1
SetVar: OLABEL=bazinga
Asterisk logs:
;Asterisk calls the first leg
[2023-03-19 06:54:36] VERBOSE[49172] pbx_spool.c: Attempting call on local/[email protected] for [email protected]:1 (Retry 1)
[2023-03-19 06:54:36] VERBOSE[49172] dial.c: Called [email protected]
[2023-03-19 06:54:36] VERBOSE[49173][C-00000028] pbx.c: Executing [[email protected]:1] NoOp("Local/[email protected];2", "Started Originate") in new stack
[2023-03-19 06:54:36] VERBOSE[49173][C-00000028] pbx.c: Executing [[email protected]:2] Answer("Local/[email protected];2", "") in new stack
[2023-03-19 06:54:36] VERBOSE[49172] dial.c: Local/[email protected];1 answered
[2023-03-19 06:54:36] VERBOSE[49172][C-00000029] pbx.c: Executing [[email protected]:1] NoOp("Local/[email protected];1", "Originate Mid Context") in new stack
;The mid-originate sends the call to originate-label,s,bazinga (the label is used from the variable)
[2023-03-19 06:54:36] VERBOSE[49172][C-00000029] pbx.c: Executing [[email protected]:2] Goto("Local/[email protected];1", "originate-label,s,bazinga") in new stack
[2023-03-19 06:54:36] VERBOSE[49172][C-00000029] pbx_builtins.c: Goto (originate-label,s,3)
;It successfully goes to the label, which is priority 3
[2023-03-19 06:54:36] VERBOSE[49172][C-00000029] pbx.c: Executing [[email protected]:3] NoOp("Local/[email protected];1", "This is the third line with a label") in new stack
[2023-03-19 06:54:36] VERBOSE[49172][C-00000029] pbx.c: Executing [[email protected]:4] Hangup("Local/[email protected];1", "") in new stack
[2023-03-19 06:54:36] VERBOSE[49172][C-00000029] pbx.c: Spawn extension (originate-label, s, 4) exited non-zero on 'Local/[email protected];1'
[2023-03-19 06:54:36] NOTICE[49172][C-00000029] pbx_spool.c: Call completed to local/[email protected]
[2023-03-19 06:54:36] VERBOSE[49173][C-00000028] pbx.c: Spawn extension (originate-alpha, s, 2) exited non-zero on 'Local/[email protected]nate-alpha-00000005;2'
So again, this looks to be like an Asterisk bug. The workaround would be to use a “pre” context that handles the Goto with a Label.