How to configure callerid

hello i had configured a Dial plan in which i am using application time base i.e

1 - if call comes to PSTN line from 8pm evening till morning 8am the call should automatically forward to guard exten i.e exten 211, and if guard dosent receive call in 30 secs message should be saved in voicemail.

2 - if call comes in working hours than it should be received by ext 112 n from there using transfer (tT)application call is tranfered to desired extensions.

now i want when i call from my mobile to pstn line my mobile no should be displayed in softphone

#######################################################################

vi extensions.conf

[from-zaptel]
exten => s,1,Wait(2)
exten => s,n,GotoIfTime(20:00-7:59|mon-sun||?closed,s,1)
exten => s,n,Dial(SIP/112,5,tT)
exten => s,n,Goto(mainmenu,s,1)

[my-phones]
exten => 112,1,Dial(SIP/112,5,T)
exten => 113,1,Dial(SIP/113)
exten => 114,1,Dial(SIP/114)

[mainmenu]
exten => s,1,Answer
exten => s,n,Noop(CALLERID(name))
exten => s,n,SetMusicOnHold(default)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Background(enter-ext-of-person)
exten => s,n,WaitExten(5)
exten => _11[2-4],1,Goto(my-phones,${EXTEN},1)
exten => i,1,Playback(pbx-invalid)
exten => t,1,Playback(vm-goodbye)

[closed]
exten => s,1,Dial(SIP/211,30)
exten => s,n,VoiceMail(211,u)
exten => 2999,1,VoiceMailMain(${CALLERID(num)},s) ; by 2999 voicemail can be heard.

#########################################################################

;autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
;autogenrated on 2010-03-18
;Dahdi Channels Configurations
;For detailed Dahdi options, view /etc/asterisk/chan_dahdi.conf.bak

[trunkgroups]

[channels]
context=default
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
relaxdtmf=yes
rxgain=0.0
txgain=0.0
group=1
callgroup=1
pickupgroup=1
immediate=no

;Sangoma AU100 [slot:0 bus: span:1]
context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 1

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 2

########################################################################

From what I understand you already have what you want by default.

When a call comes from a trunk, whatever that is, it goes to the context as it is defined in the sip.conf/iax.conf/etc.

If Caller ID is operating properly on the trunk (I am not that familiar with analog/T1 cards) on the very first line in your dialplan the ${CALLERID(number)} would be you mobile number.

You have to write lines in the dialplan to change it AFAIK.

Somewhere in the dialplan from the line of code the calls comes in, to the line of code that does the DIAL statement to your softphone, the Caller ID number is being modified.

When you call in from your mobile you seem to be entering the dialplan at [from-zaptel]. You may want to add a line there and verify that you can receive the correct Caller ID from your Zap trunk.

You can try exten => s,n,verbose(${CALLERID(num)}) after your first line (exten => s,1,Wait(2)). That would require you to be able to see the Asterisk CLI. Your name is ‘linuxguru’ so I am going to assume you can run Asterisk -rvvvvvvv from a shell :smile:

Just in case you can’t, you can have Asterisk tell you the numbers:

exten => s,n,SayDigits(${CALLERID(num)})

If it says the Caller ID is your mobile phone number then you need to track down the dialplan statement that is changing it.

P.S - It is possible that when passing the call between macros and gosub statements to have the Caller ID changed in certain situations, although I have not run into any yet. Just one of the many things I have read.

i think i had made a mistake. will i have to create a database for call log. below is the extensions.conf with cli log.its saying No application ‘DB’ for extension (from-zaptel, s, 3)

#############################################################################

CLI> – Starting simple switch on ‘DAHDI/1-1’
[Mar 20 10:59:27] NOTICE[3477]: chan_dahdi.c:8692 ss_thread: Got event 18 (Ring Begin)…
[Mar 20 10:59:27] NOTICE[3477]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
[Mar 20 10:59:27] NOTICE[3477]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
– Executing [s@from-zaptel:1] Wait(“DAHDI/1-1”, “2”) in new stack
– Executing [s@from-zaptel:2] GotoIfTime(“DAHDI/1-1”, "23:59-7:59|mon-sun|
|?closed,s,1") in new stack
[Mar 20 10:59:30] WARNING[3477]: pbx.c:3680 pbx_extension_helper: No application ‘DB’ for extension (from-zaptel, s, 3)
== Spawn extension (from-zaptel, s, 3) exited non-zero on ‘DAHDI/1-1’
– Hungup ‘DAHDI/1-1’
– Starting simple switch on ‘DAHDI/1-1’
[Mar 20 10:59:33] NOTICE[3478]: chan_dahdi.c:8692 ss_thread: Got event 18 (Ring Begin)…
[Mar 20 10:59:33] NOTICE[3478]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
[Mar 20 10:59:33] NOTICE[3478]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
– Executing [s@from-zaptel:1] Wait(“DAHDI/1-1”, “2”) in new stack
– Executing [s@from-zaptel:2] GotoIfTime(“DAHDI/1-1”, "23:59-7:59|mon-sun|
|?closed,s,1") in new stack
[Mar 20 10:59:35] WARNING[3478]: pbx.c:3680 pbx_extension_helper: No application ‘DB’ for extension (from-zaptel, s, 3)
== Spawn extension (from-zaptel, s, 3) exited non-zero on ‘DAHDI/1-1’
– Hungup ‘DAHDI/1-1’
– Starting simple switch on ‘DAHDI/1-1’
[Mar 20 10:59:38] NOTICE[3480]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
[Mar 20 10:59:39] NOTICE[3480]: chan_dahdi.c:8692 ss_thread: Got event 18 (Ring Begin)…
[Mar 20 10:59:39] NOTICE[3480]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
– Executing [s@from-zaptel:1] Wait(“DAHDI/1-1”, “2”) in new stack
– Executing [s@from-zaptel:2] GotoIfTime(“DAHDI/1-1”, "23:59-7:59|mon-sun|
|*?closed,s,1") in new stack
[Mar 20 10:59:41] WARNING[3480]: pbx.c:3680 pbx_extension_helper: No application ‘DB’ for extension (from-zaptel, s, 3)
== Spawn extension (from-zaptel, s, 3) exited non-zero on ‘DAHDI/1-1’
– Hungup ‘DAHDI/1-1’

############################################################################

extensions.conf

[from-zaptel]
exten => s,1,Wait(2)
exten => s,n,GotoIfTime(23:59-7:59|mon-sun||?closed,s,1)
exten => s,n,DB(temp/cid)=${CALLERID(all)};
exten => s,n,Dial(SIP/112,5,tT)
exten => s,n,Goto(mainmenu,s,1)

[my-phones]
exten => 112,1,Dial(SIP/112,5,T)
exten => _11X,n,Set(CALLERID(all) = ${DB(temp/cid)}
exten => _11X,n,Dial(SIP/${EXTEN})

;exten => 113,1,Dial(SIP/113)
;exten => 114,1,Dial(SIP/114)
;exten => _X.,1,Dial(DAHDI/1-1/${EXTEN})
;exten => _X.,n,Hangup

exten => 601,1,MeetMe(600,ica,1234)
exten => 600,1,MeetMe(600,icl,1234)

[mainmenu]
exten => s,1,Answer
exten => s,n,Noop(CALLERID(name))
exten => s,n,SetMusicOnHold(default)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Background(enter-ext-of-person)
exten => s,n,WaitExten(5)
exten => _11[2-4],1,Goto(my-phones,${EXTEN},1)
exten => i,1,Playback(pbx-invalid)
exten => t,1,Playback(vm-goodbye)

[closed]
exten => s,1,Dial(SIP/211,30)
exten => s,n,VoiceMail(211,u)
exten => 2999,1,VoiceMailMain(${CALLERID(num)},s) ; by 2999 voicemail can be heard.

##############################################################################

Unfortuantely, my expertise stops there. You seem to be using a packaged and pretty version like Asterisk NOW, FreePBX, or TrixBox, etc.

I work with ‘bare metal’ Asterisk boxes installed from source (some of which I have modified myself). I wrote every line of my configuration files.

For what it is worth though, I don’t think that is referring to an external database. I believe it is an outdated command trying to use the internal Asterisk database that exists. Probably a deprecated command being used on a new version of the source somehow.

I don’t know what you would need to do in the GUI to get that to change, and any changes you made to main configuration files would be overwritten by the GUI.

If you can modify the files and keep the changes look for the DB() application and replace it with the command appropriate for you version of Asterisk.

That’s my best guess…

plz tell me if i use AsteriskNow will my problem get solved. i am making pbx. what ever client wants in pbx i have done that but this i am not able 2 do. client will deffinetely will ask about the call log.

suppose i made a pbx in asterisk my diaplan is configured in such a way that when ever call comes it should be sended to exten 112 assuming exten 112 is of reception. now when reception will receive a call she should also be able 2 c the no from where call is coming.that i want to do.

what i am thinking that wehn call comes the no should be shown in cli mode. i think i have to edit channel configuration file i.e chan_dahdi.conf.

any idea

Hello,

You have to use DBput or Set(DB(…)) in order to insert something into Asterisk DB as described in this link: http://www.voip-info.org/wiki/view/Asterisk+cmd+DBput

What version of Asterisk do you have?

HTH,
Ioan.

I don’t know if Asterisk NOW will work for you or not. Personally, I detested all of them with a passion since they were impossible to configure to me.

I GAVE UP. I created a machine with CentOS 5 and installed 1.4.24 from source and never looked back. I had a couple of forums and voip-info.org, as well that famous book, ‘Asterisk: The Future of Telephony’. Then it was just reading about the functions, variables, etc.

It took me a month or two of some pretty solid work but I can tell that I can do absolutely anything with the configuration files that one of the gussied up GUI packages can do at this point, and some significantly harder things as well…

My stuff is all Realtime, which means just about everything in it is a call to an external database, which lends itself really well to comprehensive call logs and status reporting via a website.

Unfortunately, I just cannot advise you about your path with Asterisk NOW. To say I have any experience with those programs would be a lie. Well a lot of bad experience and no success stories.


As for your Caller ID absolutely you should be able to see that right away in the beginning of the dial plan. If you were able to add that code I gave you on the 2nd line of the context for the incoming trunk and do not see the Caller ID, then there is something wrong with your ZAP channel. Which, again, unfortunately is not something I can help you with either. I am pure SIP/IAX2 over here.

You want to diagnose a IAX connection between two branch offices I can help you… ZAP… sorry dude.

i belong to india. i am making pbx using sangoma fxo card. i want that when ever call comes to my PSTN line i should see the no from where call is coming. so i have to configures chan_dahdi.conf according to my region. i checked dahdi.conf and in that they have mentioned for india

######################################################################################################################
; Hide the name part and leave just the number part of the caller ID
; string. Only applies to PRI channels.
;hidecalleridname=yes
;
; Type of caller ID signalling in use
; bell = bell202 as used in US (default)
; v23 = v23 as used in the UK
; v23_jp = v23 as used in Japan
; dtmf = DTMF as used in Denmark, Sweden and Netherlands
; smdi = Use SMDI for caller ID. Requires SMDI to be enabled (usesmdi).
;
;cidsignalling=v23
;
; What signals the start of caller ID
; ring = a ring signals the start (default)
; polarity = polarity reversal signals the start
; polarity_IN = polarity reversal signals the start, for India,
; for dtmf dialtone detection; using DTMF.
; (see doc/India-CID.txt)
;
;cidstart=polarity

so i edited chan_dahdi.conf according to my region.

###############################################################################################################
vi chan_dahdi.conf

;autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
;autogenrated on 2010-03-18
;Dahdi Channels Configurations
;For detailed Dahdi options, view /etc/asterisk/chan_dahdi.conf.bak

[trunkgroups]

[channels]
context=default
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
relaxdtmf=yes
rxgain=0.0
txgain=0.0
group=1
callgroup=1
pickupgroup=1
immediate=no
;cidstart=ring
;cidstart=polarity
;callerid=asreceived
cidsignalling=polarity_IN
sendcalleridafter=2

;Sangoma AU100 [slot:0 bus: span:1]
context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 1

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 2

####################################################################################################

now when call comes to PSTN line i am not able to see the no. here is cli log

CLI> – Starting simple switch on ‘DAHDI/1-1’
[Mar 20 20:12:51] NOTICE[6659]: chan_dahdi.c:8692 ss_thread: Got event 18 (Ring Begin)…
[Mar 20 20:12:51] NOTICE[6659]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
[Mar 20 20:12:51] NOTICE[6659]: chan_dahdi.c:8692 ss_thread: Got event 17 (Polarity Reversal)…
– Executing [s@from-zaptel:1] Wait(“DAHDI/1-1”, “2”) in new stack
– Executing [s@from-zaptel:2] GotoIfTime(“DAHDI/1-1”, "23:59-7:59|mon-sun|
|*?closed,s,1") in new stack
– Executing [s@from-zaptel:3] Dial(“DAHDI/1-1”, “SIP/112,60,tT”) in new stack
== Using SIP RTP CoS mark 5
– Called 112
– SIP/112-00000000 is ringing
== Spawn extension (from-zaptel, s, 3) exited non-zero on ‘DAHDI/1-1’
– Hungup ‘DAHDI/1-1’

#################################################################################################

plz help me out.

well - I’m not a specialist for India region but I found this info on voip-info.org site:
http://www.voip-info.org/wiki/view/Asterisk+Documentation+1.6.1+India-CID.txt

Probably you have to modify your configuration of DAHDI and retest the clid detection.

Basically you have mixed cidsignalling and cidstart.

Please try with:

cidsignalling=dtmf
cidstart=polarity_IN

do you have a file with more details in doc/India-CID.txt ?

HTH,
Ioan.