Asterisk Priorities that have a possibility of matching

I want to be able to isolate only toll free numbers from my dialplan and route then through SIP instead of through a local trunk. My question is the priority numbering and it seems the toll free number would also match up with the trunk extension.

exten => _1XXXXXXXXXX,1,SetCallerID(${DEFAULT_CIDName} <${DEFAULT_CIDNum}>)
exten => _1XXXXXXXXXX,n,Dial(${TRUNK_OB}/${EXTEN:0:11})
exten => _1XXXXXXXXXX,n,Hangup

I want to be able to add:

exten => _1800NXXXXXX,1,Dial(SIP/${EXTEN})
(as well as 888, 855, 877 & 866)

but the toll free number matches the trunk Dial as well.

If I set the addition as Priority 2 and then set the trunk dial as Priority 3, would it only dial the SIP and skip the trunk or is it possible to have them both as Priority 1 and then if it’s a toll free, only dial the SIP?

I have looked everywhere and can not come up with the conclusion. Any advice would be greatly appreciated!!

“Priority” is not a priority. Priority 2 will simply compete against your first n line and priority 3 against the second one. They won’t have any more success than when matching against the priority 1 line. (n is just a shorthand for adding 1 to the priority value for the previous exten line (actually regardless of the extension field).

I think you need to use . notation, so that the general match is shorter than the specific one. If you actually need to enforce the length of match, I would do a general match in one context, and then do variable length specific matches in a second.