I have asterisk 1.6 and trying to get a called extension from a macro.
Basically my end goal is to make a agi script to get the extension called for example 315 and add 1 infront of it. As we are moving to 4 digits extension.
Following is the macro which has the Extension in it ${EXTENSION}
Verbose shows this
– Executing [s@macro-stdexten] Set(“IAX2/XXXX”, “EXTENSION=426”) in new stack
I then added this line below in the macro and I can see 426.
exten => s,n,Noop(${EXTENSION})
– Executing [s@macro-stdexten:19] NoOp(“IAX2/XXXX”, “426”) in new stack
But when I do Noop from outside the macro it returns empty.
I tried creating a global variable under that line with g option but that didn’t work. But i am not sure if i have the right cmd for it.
exten => 9502,1,NoOP()
same => n,Set(MYNUM=100)
same => n,NoOP(MYNUM is ${MYNUM})
same => n,Set(MYNUM=1${MYNUM})
same => n,NoOP(MYNUM is ${MYNUM})
same => n,Hangup()
-- Executing [9502@kiniston-intern:1] NoOp("PJSIP/7001kiniston-00000050", "") in new stack
-- Executing [9502@kiniston-intern:2] Set("PJSIP/7001kiniston-00000050", "MYNUM=100") in new stack
-- Executing [9502@kiniston-intern:3] NoOp("PJSIP/7001kiniston-00000050", "MYNUM is 100") in new stack
-- Executing [9502@kiniston-intern:4] Set("PJSIP/7001kiniston-00000050", "MYNUM=1100") in new stack
-- Executing [9502@kiniston-intern:5] NoOp("PJSIP/7001kiniston-00000050", "MYNUM is 1100") in new stack
-- Executing [9502@kiniston-intern:6] Hangup("PJSIP/7001kiniston-00000050", "") in new stack
I have managed to wrap it up. I am pasting the solution so it might help someone out there. I am not expert so this is probably not as good as it gets and probably can be done better and shorter way.
In Macro I added new global variable
[Macro]
exten => s,n(forward),Set(EXTENSION=${ARG1}) #Added my global variable ${JIX}
exten => s,n,Set(__JIX=${EXTENSION})
#My menu basically forwards the calls to Skype For Business server and adds 1 in front of extension dialed.
Verbose confirms that 4 digits are being passed to DMTF
-- Executing [s@TTest:2] Set("Local/s@TTest-f8a9;2", "XJ=1376") in new stack
-- Executing [s@TTest:3] NoOp("Local/s@TTest-f8a9;2", "1376") in new stack
-- Executing [s@TTest:4] Dial("Local/s@TTest-f8a9;2", "Local/416XXXXXXXX@internal,1,D(1376)") in new stack
Cool thanks for pointing me to right direction. Learning new stuff day by day
I used D option with w(0.5 sec delay) and it worked out fine for me. I also added a voice prompt “ExtChanged” to notify caller that 3 digits has been changed to 4 digits and that current ext is now 1+Dialed Ext which is $[XJ}.
Here is the script if someone else ever needs it in future.
Just a quick note for anyone wanting more time before sending DTMF you can add multiple wwww in there so putting 4 would mean 2 sec delay before it sends out DTMF.