Yet Another AGI question

Running the latest version of Freepbx. Need to have all outbound calls “call” an AGI script before the call is sent to the “Outbound Route”. I understand using extensions_custom.conf but want the call flow to return to Freepbx Outbound Route and Trunk logic for trunk failover etc.

Basically I want to call the AGI script for all outgoing calls and then get out of the way.

Sorry if this has been asked before. I have scoured the forum but I must not be following something. Ive have Freepbx up for several weeks and it seems to be working great. I have worked with vanilla asterisk in the past and really like how Freepbx takes a lot of the complexity out of using asterisk.

There is a predefined context specifically for this purpose. Add this to /etc/asterisk/extensions_custom.conf and reload the dialplan:

[macro-dialout-trunk-predial-hook] exten=> s,1,Noop(This macro will execute on all outbound calls) exten=> s,2,AGI( ... etc...)