Passing an arg to a custom app from IVR module or calling a Macro

Version: freePBX 2.2.0rc3

I want to be able to pass a value to a custom app from the IVR menu or call a Macro with an arg. In the IVR menu you can select:

Custom App

I have a macro that will transfer calls by flashing the ZAP channel sending DTMF and hanging up. What I want to be able to do is convert that macro into a custom app and then enter something like “transfer,1234” in the Custom App field where 1234 is an extension.

This transfer feature works great if I go back and manually replace the call for the custom app with the Macro function call. It would be great if I didn’t have to do this as I want non-technical (as in non UNIX admins) to be able to edit this IVR.

The reason for doing it this was over using Core is to not waste Zap channels.



Test IVR written by freepbx and then edited manually:

include => ivr-3-custom
include => ext-findmefollow
include => ext-local
exten => h,1,Hangup
exten => s,1,Set(LOOPCOUNT=0)
exten => s,n,Set(__DIR-CONTEXT=)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Background(custom/techdept)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
exten => 1,1,Goto(ext-local,116,1)
exten => 2,1,Goto(ext-recordings,recording-3,1)
exten => 3,1,Macro(transfer,4767)
exten => i,1,Playback(invalid)
exten => i,n,Goto(loop,1)
exten => t,1,Goto(loop,1)
exten => loop,1,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten => loop,n,GotoIf($[${LOOPCOUNT} > 2]?hang,1)
exten => loop,n,Goto(ivr-3,s,begin)
exten => fax,1,Goto(ext-fax,in_fax,1)

Tranfer Macro:

exten => s,1,Background(silence/1)
exten => s,2,Flash()
exten => s,3,Background(silence/1)
exten => s,4,SendDTMF(${ARG1},400)
exten => s,5,Background(silence/1)
exten => s,6,Hangup()

This is the work around I am using. I type “transfer,1234” where 1234 is the 4 digit extension into the Custom App text box in the IVR.

I added the following to the init script for asterisk:

Transform Goto(transfer into Macro(transfer

sed -i ‘s/Goto(transfer/Macro(transfer/’ extensions_additional.conf

This finds all instances of “Goto(transfer” and replaces them with “Macro(transfer”.

I also shortened by transfer macro to:

exten => s,1,Flash()
exten => s,2,Background(silence/1)
exten => s,3,SendDTMF(${ARG1},400)
exten => s,4,Hangup()