Executing an agi-bin before outgoing calls

I am trying to include a call to an agi-bin when any external number is being dialed (or when any call is being placed). I created a custom context like this:

[from-internal-custom] exten => _.,1,Noop(calling agi-bin) exten => _.,n,AGI(anv-llamada-saliente.agi,${EXTEN})

It works. An call is passed through through this dialplan. But some feature codes stops working.

How can I include the execution of this instruction wihout loosing other features?

I look forward to an answer to this myself.

The problem I think is that the dialplan priority keeps increasing. In your example it would be at 2 after the last line of from-internal-custom, and would then carry on to from-internal at priority 3, skipping whatever was at 1 and 2.

But this effectively renders the entire idea of the -custom contexts useless, which I don’t see being the case.

Then… I should add a goto from-internal 1…

But I just found a solution:

[macro-dialout-trunk-predial-hook] exten => s,1,NoOp(Outgoing call throug trunk ${OUT_${DIAL_TRUNK}} to ${EXTEN} - ${OUTNUM}) exten => s,n,AGI(anv-llamada-saliente.agi,${OUTNUM}) exten => s,n(skip),MacroExit()

Then… I should add a goto from-internal 1…

But I just found a solution:

[macro-dialout-trunk-predial-hook] exten => s,1,NoOp(Outgoing call throug trunk ${OUT_${DIAL_TRUNK}} to ${EXTEN} - ${OUTNUM}) exten => s,n,AGI(anv-llamada-saliente.agi,${OUTNUM}) exten => s,n(skip),MacroExit()