How to set different outbund callerID for different phones?

Hello everybody!

I have eicon PRI(30) card working with my asterisk 1.4.1 both inbound and outbound.
From PSTN provider i got 100 DIDs - from XXXXX00 to XXXXX99.
Now i can set my caller ID to any number from that range with:

exten => _X.,1,SET(CALLERID(all)=My company name<1234567>)
;where 1234567 is any number from range (XXXXX00 - XXXXX99)

exten => _X.,2,Dial(CAPI/contr1/${EXTEN})

and also i can hide my caller id with:

exten => _X.,1,SetCallerPres(prohib_not_screened)
exten => _X.,2,Dial(CAPI/contr1/${EXTEN})

My question is: can i set different outbound callerID for different phones (10 cisco 7940 phones) and hide outbound callerID for some other phones (20 cisco 7940)???

Ok, that isn’t my real question, i know that is possible, but the real question is HOW can i do that???

Please help me! :frowning:

Thank you in advance!!! :smiley:

You could try check the caller id before setting it, it should contains the caller id of the sip phone which originated the call, so check the variable CALLERID() and then go to the right extension with the GotoIf command, then in this extension you set or hide the caller id.
Didn’t try but should work.

Regards.

Marco Bruni

You can change the caller ID number, but not the name. The name is set by your E1 provider.

An other option is to make a context for every phone you have and set the callerid and other phone related variables in that context and include the more general context. In the sip entry in sip.conf you use the phone related context (f.i. context=5000 for phone 5000) With 500 phones I wouldn’t do it this way but with 10 phones I think it is the easiest way.

[5000] ; phone number

exten => 1,1,Set(CallerID(num)=0592111110) ; check the syntax I’m not completely sure
include => all_rights

[5001]
exten => 1,1,Set(CallerID(num)=0592111111) ; check the syntax I’m not completely sure
include => only_local

This way you can make different contexts with different level of priviliges and include the one that fits what you have in mind for the number. (only internal, internal and local, internal, local and national, all numbers in the universe). You can make this work with numbermatching.

That could be an awful lot of contexts to have. We have hundreds of users. We use a database that stores the outbound caller ID number for each phone, if different for the actual phone number itself.

For example, many customers prefer to have the main number of the company set as the caller ID number.

With hundreds of numbers it is not a proper way to deal wth this. But with 10 phones and 10 numbers it is an easy way to do it this way, in combination with implementing different levels of privileges it is a transparant way to build a dial plan by editing the extensions.conf and sip.conf

With hundreds of numbers and all kind of dialplan logic (queues, groups, menus, routes etc.) my advice is to use a proper gui that helps you to configure, maintain and monitor your Asterisk server. ScopServ (www.scopserv.com) is, in my humble opinion, the best choice for this. Just download the trial version and come to your own conclusions.

in [globals]
CID4563=1XXXXXX4563

for each DID I have.

then I do this will all outbound calls:

[outgoing]
exten => _1NXXNXXXXXX,1,Set(SVID=CID${CALLERIDNUM})
exten => _1NXXNXXXXXX,2,Set(CNAME=${CALLERIDNAME})
exten => _1NXXNXXXXXX,3,Set(CALLERID(number)=${CALLERIDNUM})
exten => _1NXXNXXXXXX,4,gotoif($[“test${CID${CALLERIDNUM}}” = “test”]?101:5)
exten => _1NXXNXXXXXX,5,Set(CALLERID(all)=“Company-${CNAME}” <${${SVID}}>)
exten => _1NXXNXXXXXX,6,goto(dial_sip_did,${EXTEN},1)
exten => _1NXXNXXXXXX,101,goto(dial_sip_no_did,${EXTEN},1)

[dial_sip_did]
exten => _X.,1,dial(SIP/sip_gateway/${EXTEN})
1exten => _X.,n,Congestion

[dial_sip_no_did]
exten=>_X.,1,Set(CALLERID(all)=“Company Name” <1XXXXXXXXXX>)
exten=>_X.,n,dial(SIP/sip_gateway/${EXTEN})
exten=>_X.,n,congestion

1.4.11 has broken my callerid setting above, but I’m working it out now and will post a followup when done.

Thank you all for helping me!

Finally i have my Asterisk 1.4.11 working well.
Hiding ID for some phones, and setting different callIDs for other phones was very hard for me few weeks ago, but now everything looks very easy…


extensions.conf

exten => _X.,10,Gotoif($[${CALLERID(num)}=109]?35:40)
;;; if phone 109 is making a call - goto 35, otherwise goto 40

exten => _X.,35,SetCallerPres(prohib_not_screened)
;;; hide callerID (works on my eicon PRI/30 card)

exten => _X.,36,Dial(CAPI/contr1/${EXTEN})

exten => _X.,40,SET(CALLERID(all)=My company name<5555555>)
;; set caller ID (5555555)

exten => _X.,41,Dial(CAPI/contr1/${EXTEN})


Also, i figured out how asterisk can receive fax messages.

This is part of my extensions.conf for recieving fax messages.

First, when somebody call phone number XXX3499 - asterisk pass that call to [fax]

exten => 3499,1,Goto(fax,s,1)

[fax]
exten => s,1,capicommand(receivefax|/fax/${UNIQUEID}.sff)
;;; Asterisk is recieving fax in file ${UNIQUEID}.sff placed in folder /fax/

exten => h,1,System(sfftobmp -j -f /fax/*.sff)
;;; use sfftobmp to convert from sff to jpg

exten => h,n,System(mv *.jpg /faxIN/)
;;; move .jpg fax in folder /faxIN

exten => h,n,System(rm -f /fax/*)
;; remove .sff file

exten => h,n,System(sam2p /faxIN/*.jpg PDF: /faxPDF/${UNIQUEID}.pdf)
;;; convert fax from .jpg to .pdf using sam2p

exten => h,n,System(rm -f /faxIN/*)
;;; remove .jpg fax file

exten => h,n,System(mv -f /faxPDF/${UNIQUEID}.pdf
/faxPDF/${STRFTIME(${EPOCH},%d-%m-%Y–%H-%M-%S)}.pdf)
;;; rename ${UNIQUEID}.pdf to DD-mm-YY–HH-MM-SS.pdf

exten => h,n,System(ncftpput -u username -p password -P 23 192.168.1.XXX / /faxPDF/${STRFTIME(${EPOCH},%d-%m-%Y–%H-%M-%S)}.pdf)
;;; upload recieved .pdf fax file to user winXP computer using ncftp trought ftp

exten => h,n,System(echo New FAX received! Look file ${STRFTIME(${EPOCH},%d-%m-%Y–%H-%M-%S)}.pdf |smbclient -M hostname -U Asterisk)
;;; send popup message to winXP using smbclient


Maybe this could be usefull for somebody…