Specific Outbound Trunk per Extension

I am trying to phase asterisk, to prove its greatness, into an exisiting phone system. The only hang up (no pun intended) is that when a user dials an outside line, I need to be able to specify which Zap channel to use (that way extension 411 looks like extension 411 on the older phone systems caller IDs).

I was thinking that I could use some combination of GotoIf and MACRO_EXTEN to make this magic happen. Right now I’m only concerend with two extensions and zap channels. I would like, when a person dials from “SIP/411” that they get Zap/2 and when they dial from “SIP/299” the get Zap/3 for the _9NXXXXXXX or _91NXXNXXXXXX extensions. I just can’t figure it out though - I’m fairly new to this and would really like to make Asterisk shine - everything else works great.

You could use some goto ifs based on the callerid or you could have seperate contexts and specify individual contexts for 411 and 299, example below:

[411]
secret=411
type=friend
context=411

[299]
secret=299
type=friend
context=299

Would this work - I posted my extensions.conf, zapata.conf, sip.conf? See any problems?

extensions.conf:
[globals]

[411]
ZCHAN=2
MYEXTEN=411
include => incoming-sip-myexten
include => internal-all
include => outbound

[299]
ZCHAN=3
MYEXTEN=299
include => incoming-sip-myexten
include => internal-all
include => outbound

[internal-all]
exten => 411,1,Macro(sip-dialed)
exten => 299,1,Macro(sip-dialed)
exten => 500,1,VoiceMailMain()

[incoming-sip-myexten]
exten => s,1,Dial(SIP/${MYEXTEN},30,r)
exten => s,2,VoiceMail(u${MYEXTEN}@default)
exten => s,102,VoiceMail(b${MYEXTEN}@default)

[macro-sip-dialed]
exten => s,1,Dial(SIP/${MACRO_EXTEN},30,r)
exten => s,2,VoiceMail(u${MACRO_EXTEN}@default)
exten => s,102,VoiceMail(b${MACRO_EXTEN}@default)

[outbound]
exten => _8NXX,1,Dial(Zap/${ZCHAN}/${EXTEN:1})
exten => _8NXX,2,Congestion()
exten => _8NXX,102,Congestion()
exten => _9NXXXXXX,1,Dial(Zap/${ZCHAN}/${EXTEN})
exten => _9NXXXXXX,2,Congestion()
exten => _9NXXXXXX,102,Congestion()
exten => _91NXXNXXXXXX,1,Dial(Zap/${ZCHAN}/${EXTEN})
exten => _91NXXNXXXXXX,2,Congestion()
exten => _91NXXNXXXXXX,102,Congestion()

zapata.conf
[trunkgroups]

[channels]
usecallerid=yes
hidecallerid=no
callwaiting=no
threewaycalling=yes
transfer=yes
echocancel=yes
echotraining=yes

;Physical Channels
context=411
signalling=fxo_ks
channel=>2

context=299
signalling=fxo_ks
channel=>3

sip.conf
[general]
context=default
allow=ulaw
bindport=5060
bindaddr=0.0.0.0
srvlookup=yes
localnet=10.1.0.0/255.255.0.0

[411]
type=friend
secret=welcome
canreinvite=no
qualify=yes
host=dynamic
context=411

[299]
type=friend
secret=welcome
canreinvite=no
qualify=yes
host=dynamic
context=299