Where to put this?

Hi,
I want to call a script whenever there’s a call on specific numbers.
This is what I have tried so far:

[from-internal-custom]
exten => _X.,1,System(...)

It does kind of work, the script is executed, but calls don’t come through anymore, every call results in a “Auto fallthrough, channel ‘…’ status is ‘UNKNOWN’” in the end.

I don’t want to modify the supplied freepbx-dialplan. So, where’s the right hook, where I can put this?

The reason is because after you make the system call, you’re not doing anything else with the call. In order to send it back into the dial plan, you need an additional line of dial plan code, and that depends on where the call would go but for the fact that you’ve inserted your system call. For example, let’s suppose the call would have gone to from-internal - then your next line might be:

exten => _X.,n,Goto(from-internal,${EXTEN},1)

On the other hand, if you’re intercepting a call coming in from a trunk, then you do not want to send it to from-internal (unless you like paying for other people’s calls), but rather to from-trunk:

exten => _X.,n,Goto(from-trunk,${EXTEN},1)

that doesn’t do the trick either, now it just says:

    -- Goto ( from-internal, 26,1)

And that’s it.

[from-internal-custom] is included from [from-internal], so it should just go on without any gotos.
And it does, I can see that some other included context executes the callerid-macro, which in the end says NoOp(… Using CallerID …), after that I get the auto fallthrough.

another interesting observation:
the exact same thing works without any problems in [from-pstn-custom]…

and I’ve missed something, that may be related to my problem:

 -- Executing [[email protected]:2] Goto("SIP/39-0000000e", ",return,1") in new stack
    -- Goto (from-internal,return,1)
    -- Executing [[email protected]:1] Macro("SIP/39-0000000e", "hangupcall") in new stack

So, I guess that’s the

in [ext-local] being executed, because I’ve overwritten the one with priority 1 (???)

I discovered another hook, in [macro-exten-vm] there is a include => macro-exten-vm-custom, but i really can’t get this working.
This doesn’t work:

[macro-exten-vm-custom] exten => s,1,NoOp("test")

The only other thing I can suggest is looking at some of the FreePBX documentation, especially the How To section (http://www.freepbx.org/support/documentation/howtos) - there might be something there that is very similar to what you want to do.