[asterisk-users] Changing callerID in a context

Atis Lezdins atis at iq-labs.net
Fri Aug 22 07:47:34 CDT 2008


On Thu, Aug 21, 2008 at 3:11 PM, Andy Dixon <ajd at malcol.org> wrote:
> Hello,
>
> I am trying to alter the outbound callerID for extensions within a
> context I have created.
>
> I wrote the following:
>
> exten => _9.,2,ExecIf($[$["${REALCALLERIDNUM}" = "360"] | $["$
> {REALCALLERIDNUM}" = "670"]]|Set|CALLERID(num)=581560)
> exten => _9.,3,ExecIf($[$["${REALCALLERIDNUM}" = "361"] | $["$
> {REALCALLERIDNUM}" = "671"]]|Set|CALLERID(num)=581561)
> exten => _9.,4,ExecIf($[$["${REALCALLERIDNUM}" = "362"] | $["$
> {REALCALLERIDNUM}" = "672"]]|Set|CALLERID(num)=581562)
> exten => _9.,5,ExecIf($[$["${REALCALLERIDNUM}" = "363"] | $["$
> {REALCALLERIDNUM}" = "673"]]|Set|CALLERID(num)=581563)
> exten => _9.,6,ExecIf($[$["${REALCALLERIDNUM}" = "364"] | $["$
> {REALCALLERIDNUM}" = "674"]]|Set|CALLERID(num)=581564)
> exten => _9.,7,ExecIf($[$["${REALCALLERIDNUM}" = "365"] | $["$
> {REALCALLERIDNUM}" = "675"]]|Set|CALLERID(num)=581565)
> exten => _9.,8,ExecIf($[$["${REALCALLERIDNUM}" = "366"] | $["$
> {REALCALLERIDNUM}" = "676"]]|Set|CALLERID(num)=581566)
> exten => _9.,9,ExecIf($[$["${REALCALLERIDNUM}" = "367"] | $["$
> {REALCALLERIDNUM}" = "677"]]|Set|CALLERID(num)=581567)
> exten => _9.,10,ExecIf($[$["${REALCALLERIDNUM}" = "368"] | $["$
> {REALCALLERIDNUM}" = "678"]]|Set|CALLERID(num)=581568)
> exten => _9.,11,ExecIf($[$["${REALCALLERIDNUM}" = "369"] | $["$
> {REALCALLERIDNUM}" = "679"]]|Set|CALLERID(num)=581569)
> exten => _9.,12,ExecIf($[$["${REALCALLERIDNUM}" = "700"] | $["$
> {REALCALLERIDNUM}" = "701"]]|Set|CALLERID(num)=581557)
> exten => _9.,13,ExecIf($[$["${REALCALLERIDNUM}" = "100"] | $["$
> {REALCALLERIDNUM}" = "101"]]|Set|CALLERID(num)=581500)
>
>
> This *should* change the callerID for (for example) 700 and 701 to be
> 581557, and any extensions not listed above, it should leave them alone.
>
> If I call from extension 666, I get the correct outbound number (as it
> does exist), but the rules above are not being followed.
>
> I have tried to use Set(CALLERID(num)=581500) which works okay
> slightly further down.
>
> I am aiming for any numbers starting with a 9 to follow the rules
> above, and then to follow a further rule (eg if the number starts 901,
> or 907)
>
> I'm stuck.. If anyone could help, I would be eternally grateful..

Are you sure ${REALCALLERIDNUM} is set? Alternatively (to AEL) there's
a way how to simplify all this, by using Asterisk extension patterns:

[clid-mangle]
exten => 70[01],1,Set(CALLERID(num)=581557)
exten => 70[01],2,Return()
exten => 10[01],1,Set(CALLERID(num)=581500)
exten => 10[01],2,Return()
; and so on, just better reorganize your extensions so that this can
match patterns better.

[dial-out]
exten => _9.,1,GoSub(clid-mangle,${CALLERID(num)},1)
exten => _9.,2,Dial(SIP/provider)



Regards,
Atis

-- 
Atis Lezdins,
VoIP Project Manager / Developer,
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835



More information about the asterisk-users mailing list