I solve that problem by putting all of my dial strings into different contexts. They’re grouped by type of call that I want to control.
Each context is listed in the order I want them to be matched using include => statements later in other contexts. They are checked in the order that the include => statements are listed.
I also use macro’s to dial my calls, so the treatment can be worked into the individual contexts with a single line.
So it would look like this:
[tollfree]
exten => _1888NXXXXXX,1,Macro(dialzapcard)
exten => _1877NXXXXXX,1,Macro(dialzapcard)
exten => _1866NXXXXXX,1,Macro(dialzapcard)
exten => _1855NXXXXXX,1,Macro(dialzapcard)
exten => _1800NXXXXXX,1,Macro(dialzapcard)
[international]
exten => _011.,1,Macro(dialzapcard)
[blockedcalls]
exten => _1900NXXXXXX,1,Congestion
exten => _1NXX976XXXX,1,Congestion
exten => _1NXX550XXXX,1,Congestion
[default]
include => blockedcalls
include => tollfree
include => international
In my short example, the blocked calls are checked first and stopped first by simply playing the Congestion signal. Then a check is made to see if it’s toll free, and then an international call, both of which are allowed to use the zapcard to dial out.
Using this method, you can also put your extensions into contexts like [lobby], [executive] or [receptionist] and you can include =>, or leave out, the types of calls you would want them to be able to place.
[lobby]
include => blockedcalls
include => tollfree
exten => 31,1,Macro(callextension,${LOBBYSIP})
In this example, the lobby phone at extension 31 can place toll free calls, but the [international] context isn’t inserted with an include => statement. So, it can’t place international calls.
You may want to create other classes of call types. Such as 411, 911, local, long distance, toll free, international, broadband, and internal. Each call type could be allowed or disallowed by using an include => statement or leaving them out.