Hi all. First of all, I’m comfortable with stock asterisk using it since 1.2 but not with FreePBX.
I want to check how I could add my dialplan rules for various scenario. So I try to add my own PJSIP_HEADERS and saw that I could do it in macro-dial-one just before the dial. I also add a channel variable for incoming calls from trunk, which is called DIALEDNUMBER. In macro-dial-one I set
exten => s,n,ExecIf($[“${ivrreturn}” = “1”]?Set(D_OPTIONS=${D_OPTIONS}g))
same = n,NoOp(DIALEDNUMBER=${DIALEDNUMBER})
same = n,ExecIf($[“x${DIALEDNUMBER:-4}” = “x0089”]?Gosub(func-set-sipheader,s,1(Alert-Info,blabla;info=Private-DH;x-line-id=0)))
exten => s,n(dial),Dial(${DSTRING},${ARG1},${D_OPTIONS}${CWRING}b(func-apply-sipheaders^s^1))
With result being
-- Executing [s@macro-dial-one:55] ExecIf("Local/807@from-queue-0000000e;2", "0?Set(D_OPTIONS=HhTtrM(auto-blkvm)g)") in new stack
-- Executing [s@macro-dial-one:56] NoOp("Local/807@from-queue-0000000e;2", "DIALEDNUMBER=XXXXXX0089") in new stack
-- Executing [s@macro-dial-one:57] ExecIf("Local/807@from-queue-0000000e;2", "1?Gosub(func-set-sipheader,s,1(Alert-Info,blabla;info=Private-DH;x-line-id=0))") in new stack
== Channel ‘Local/807@from-queue-0000000e;2’ jumping out of macro ‘dial-one’
== Channel ‘Local/807@from-queue-0000000e;2’ jumping out of macro ‘exten-vm’
– Executing [s@func-set-sipheader:1] NoOp(“Local/807@from-queue-0000000e;2”, “Sip Add Header function called. Adding = HhTtrM(auto-blkvm)”) in new stack
– Executing [s@func-set-sipheader:2] Set(“Local/807@from-queue-0000000e;2”, “HASH(__SIPHEADERS,)=HhTtrM(auto-blkvm)”) in new stack
– Executing [s@func-set-sipheader:3] Return(“Local/807@from-queue-0000000e;2”, “”) in new stack
So jumping out of queue twice and adding Sip Header HhTtrM(auto-blkvm) !!!
Now I remove the ExecIf($[“x${DIALEDNUMBER:-4}” = “x0089”]? which now looks like
same = n,Gosub(func-set-sipheader,s,1(Alert-Info,blabla;info=Private-DH;x-line-id=0))
and get
-- Executing [s@macro-dial-one:55] ExecIf("Local/807@from-queue-00000011;2", "0?Set(D_OPTIONS=HhTtrM(auto-blkvm)g)") in new stack
-- Executing [s@macro-dial-one:56] NoOp("Local/807@from-queue-00000011;2", "DIALEDNUMBER=XXXXXX0089") in new stack
-- Executing [s@macro-dial-one:57] Gosub("Local/807@from-queue-00000011;2", "func-set-sipheader,s,1(Alert-Info,blabla;info=Private-DH;x-line-id=0)") in new stack
-- Executing [s@func-set-sipheader:1] NoOp("Local/807@from-queue-00000011;2", "Sip Add Header function called. Adding Alert-Info = blabla;info=Private-DH;x-line-id=0") in new stack
which is the right result.
Anyone has an idea on this ? Should I open an issue ?
Daniel