Calling a macro from a macro

I would like to pass all incoming calls through a macro which checks cli and then directs the call on to another macro with arguments based on who called.

I’m using hangup_handler to run further dialplan configuration after the call has completed.

how can I call a macro from another macro without using gosub, or should I be using gosub? Can you use hangup_handler in gosub?


I would recommend using Gosub over macro, There are issues when you nest macro’s deeper than a few levels.

I believe you should be able to set a hangup handler anywhere because they apply to the channel for the call not just to where the call is in your dialplan.

You could likely do what you want without nesting at all if you are smart with your design and pass arguments back to your dialplan from your Gosubs with RETURN()

You could have

exten => s,1,NoOP()
same => n,Gosub(callerid-lookup,s,1)
same => n,NoOP(Returned Value is ${GOSUB_RETVAL})
same => n,Gosub(call-director,s,1(${GOSUB_RETVAL}))