I’m having a weird issue - probably due to ignorance - with a bit of asterisk dialplan. I am attempting to get only certain calls to apply a SIP header with the below dialpan:
[macro-dialout-one-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-one-predial-hook in extensions_custom.conf)
exten => s,n,Set(ACCOUNTCODE=${DB(AMPUSER/${CALLERID(dnid)}/accountcode)})
exten => s,n,Noop(${ACCOUNTCODE})
exten => s,n,GotoIf("${ACCOUNTCODE}" = "Folsom"]?special)
exten => s,n,MacroExit
exten => s,n(special),Noop(Auto Answer Call)
exten => s,n,Gosub(func-set-sipheader,s,1(Alert-Info,Auto Answer))
exten => s,n,MacroExit
Essentially I am trying to lookup the accountcode for the called party, and if it matches the value specified in the dialplan, move forward with applying the sip header. If not, it should exit (I think).
Here is the snippet of my test call, where I expected it to exit prior to applying the headers. At this point, all calls are applying the sip header which is not intended:
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dial-one:50] Macro("PJSIP/507-0000184b", "dialout-one-predial-hook,") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dialout-one-predial-hook:1] NoOp("PJSIP/507-0000184b", "Entering user defined context macro-dialout-one-predial-hook in extensions_custom.conf") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dialout-one-predial-hook:2] Set("PJSIP/507-0000184b", "ACCOUNTCODE=Layer7") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dialout-one-predial-hook:3] NoOp("PJSIP/507-0000184b", "Layer7") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dialout-one-predial-hook:4] GotoIf("PJSIP/507-0000184b", ""Layer7" = "Folsom"]?special") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx_builtins.c: Goto (macro-dialout-one-predial-hook,s,6)
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dialout-one-predial-hook:6] NoOp("PJSIP/507-0000184b", "Auto Answer Call") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@macro-dialout-one-predial-hook:7] Gosub("PJSIP/507-0000184b", "func-set-sipheader,s,1(Alert-Info,Auto Answer)") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@func-set-sipheader:1] NoOp("PJSIP/507-0000184b", "Sip Add Header function called. Adding Alert-Info = Auto Answer") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@func-set-sipheader:2] Set("PJSIP/507-0000184b", "HASH(__SIPHEADERS,Alert-Info)=Auto Answer") in new stack
[2023-07-20 11:26:41] VERBOSE[29889][C-00000ab0] pbx.c: Executing [s@func-set-sipheader:3] Return("PJSIP/507-0000184b", "") in new stack
I’m rubbish with asterisk dialplan so any help is appreciated.