Routing outgoing call baset on ext origin

I have search around this forum and by google and not found the solution yet, maby I just can´t figure the right keywords, but …

I have 2 public sip accounts, one from viptel.dk (fooprovider_out1) and one from alltele.se (fooprovider_out2), I have 2 ext ((SIP/1000) and (SIP/1001))

I like to have ALL calls from (SIP/1000) go out via (fooprovider_out1) without any leading prefix and the same for (SIP/1001) via (fooprovider_out2)

Any one that can point me in the right direction

Thanks

How about something like this…
same => n,ExecIf($["${CALLERID(num)}" = “1000”]?Dial(SIP/fooprovider_out1/${EXTEN}):ExecIf($["${CALLERID(num)}" = “1001”]?Dial(SIP/fooprovider_out2/${EXTEN}):NoOP(Conditions did not match)))

–Satish Barot

[quote=“satish4asterisk”]How about something like this…
same => n,ExecIf($["${CALLERID(num)}" = “1000”]?Dial(SIP/fooprovider_out1/${EXTEN}):ExecIf($["${CALLERID(num)}" = “1001”]?Dial(SIP/fooprovider_out2/${EXTEN}):NoOP(Conditions did not match)))

–Satish Barot[/quote]

Smart, I have not used the “same =>” before, shall I have a “exten =>” first?

weee, I got it working :smile:

Noe i just want to ask a little question that for me is the most obvious thing, but i just like to get confirmed.

the [myphones] section will be read from the top down every time a new call is made,
so if i have

[myphones]
exten => 1000,1,Dial(SIP/1000)
exten => 1000,n,Hangup()

exten => 1001,1,Dial(SIP/1001)
exten => 1001,n,Hangup()

exten => _X.,1,NoOp()
same => n,ExecIf($["${CALLERID(num)}" = “1000”]?Dial(SIP/fooprovider_out1/${EXTEN}):ExecIf($["${CALLERID(num)}" = “1001”]?Dial(SIP/fooprovider_out2/${EXTEN}):NoOP(Conditions did not match)))
exten => _X.,n,Hangup()

Then it looks for 100 then 1001 then any other number more than 3 digits, is that correct?
And if I made it like:
[myphones]
exten => _X.,1,NoOp()
same => n,ExecIf($["${CALLERID(num)}" = “1000”]?Dial(SIP/fooprovider_out1/${EXTEN}):ExecIf($["${CALLERID(num)}" = “1001”]?Dial(SIP/fooprovider_out2/${EXTEN}):NoOP(Conditions did not match)))
exten => _X.,n,Hangup()

exten => 1000,1,Dial(SIP/1000)
exten => 1000,n,Hangup()

exten => 1001,1,Dial(SIP/1001)
exten => 1001,n,Hangup()

It will never get to thw 1000 and 1001?

_X. looks for any number starting with 0-9 end containing at least 2 digits.
However: Within one context an exact match (in Your case 1000 or 1001) is higher priorized than any non-exact pattern match. This means: Anyl call to 1000 or 1001 will be handeld by the respective dedicated extensions while any call to any other number will be handled by the _X.-pattern. The ordering of the extensions in the same context doen’t play any role in newer asterisk versions. (For a more detailled example look here https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching

[quote=“abw1oim”]_X. looks for any number starting with 0-9 end containing at least 2 digits.
However: Within one context an exact match (in Your case 1000 or 1001) is higher priorized than any non-exact pattern match. This means: Anyl call to 1000 or 1001 will be handeld by the respective dedicated extensions while any call to any other number will be handled by the _X.-pattern. The ordering of the extensions in the same context doen’t play any role in newer asterisk versions. (For a more detailled example look here https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching[/quote]

Thank You,
I was just wondering if it was done heretical or by weight