Outbound line priority

I’m wondering if it’s possible to give a specific outbound line to someone dialing long distance as oppose to local calling. Here is a simplified version of what I have in mind:

line 1: Unlimited long distance
line 2: pay per use long distance
line 3: no long distance

if you dial 1, the phone system grabs line 1, or line 2. if you dial local, the system grabs line 3 or line 2. Is this possible? Can you do this without entering a special code?

The idea is to optimally utilize the long distance plan, and not waste 5 flat rate lines on mostly local calling.

Yes but you dont need to press anybutton you can siply set up your dial plan to choose the proper line based on the number that was dialed.

for instance if local calling was area code 516 then you would have all calls that are dialed with 516 in the begining to use a certain line. All other calls to use the reg line.

;This will catch all calls that start with 1516 and send it to SipProviderA
Exten => _1516XXXXXXX,1,Answer
Exten => _1516XXXXXXX,2,Dial(SIP/${EXTEN}@SipProviderA)
Exten => _1516XXXXXXX,3,Hangup

;This will catch all other calls and then send them to sip provider B
Exten => _1NXXXXXXXXX,1,Answer
Exten => _1NXXXXXXXXX,2,Dial(SIP/$EXTEN}@SipProviderB)
Exten => _1NXXXXXXXXX,3,Hangup

The set up here was done asuming that you are using sip. If you are using zap then you would configure it apropiately.

Thanks for the info! I was hoping to extend that a bit. Does this work?

A = local
B = long distance 1
C = long distance 2

;try line 1
Exten => _NXXXXXX,1,Answer
Exten => _NXXXXXX,2,Dial(SIP/${EXTEN}@SipProviderA)
Exten => _NXXXXXX,3,Hangup

;if line 1 is used, try line 2
Exten => _NXXXXXX,1,Answer
Exten => _NXXXXXX,2,Dial(SIP/${EXTEN}@SipProviderB)
Exten => _NXXXXXX,3,Hangup

;try line 3
Exten => _1NXXXXXXXXX,1,Answer
Exten => _1NXXXXXXXXX,2,Dial(SIP/$EXTEN}@SipProviderC)
Exten => _1NXXXXXXXXX,3,Hangup

;if pickup line 3 fails, try line 2
Exten => _1NXXXXXXXXX,1,Answer
Exten => _1NXXXXXXXXX,2,Dial(SIP/$EXTEN}@SipProviderB)
Exten => _1NXXXXXXXXX,3,Hangup

Pardon my ignorance