Redirecting outbound dialed numbers

There is a pre-defined macro context that is called just before the number is dialed [macro-dialout-trunk-predial-hook]. By creating some dialplan in this context, you can use outbound number, in a SQL query (or API call) and redirect the call if the lookup returns a value. Additional reading: