Not Logged in - No Account?
Don't have an account? Registering an account with us allows you to post to the forums, easily track new posts, subscribe to threads, pm (private message) other forum members, and receive periodic news letters (you can opt out if you desire). Once you are logged in this message will no longer appear. If you don't have an account, you can create one by registering here. Lost your password, request a new password. We respect your privacy which means we collect minimal information when you register and we do not resell that information or use it in any objectionable way. You can review our privacy policy for full details.
How to change incoming CallerID
How to change incoming CallerID
The following is an example of how to add a digit to incoming
CallerID on a particular trunk - some people seem to want this because
their phones will not do a proper callback if the leading digit(s) are
missing.
Step 1: Go into the trunk for that provider (if not a Zap trunk-see
below for Zap) and under Incoming Settings | USER details you will see
a "context=" line - usually this will be "context=from-trunk". Note
what is there now (if it is something other than "from-trunk") and
change it to "from-trunk-custom", or add "-custom" to the end of
whatever is there now
Step 2: Edit etc/asterisk/extensions_custom.conf (you can use nano,
Midnight Commander's built-in editor, or other plain-text editor of
your choice) and add the following at the bottom of the file:
[from-trunk-custom]
exten => _X.,1,Set(CALLERID(num)=0${CALLERID(num)})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)
Again, change the "from-trunk" in the first and third lines if you
originally had something else in your trunk context. In the SECOND
line, the 0 (following the =) is the digit to be added - if you want to
add something other than 0, you'll have to change that.
Step 3: Restart Asterisk
From CLI: restart now (or, restart when convenient if you don't want to drop calls)
OR, from command line: amportal restart
If you need to make this change for your Zap trunk, the procedure is slightly different:
Step 1: Edit etc/asterisk/zapata.conf (you can use nano, Midnight
Commander's built-in editor, or other plain-text editor of your
choice). You will see a "context=" line - usually this will be
"context=from-zaptel". Note what is there now (if it is something other
than "from-zaptel") and change it to "from-zaptel-custom", or add
"-custom" to the end of whatever is there now.
Now continue with Steps 2 and 3 above, substituting "from-zaptel"
(or whatever you found in the "context=" line in zapata.conf) in place
of "from-trunk" in lines 1 and 3 of Step 2 (i.e., just replace "trunk"
with "zaptel" in those lines).
Note that the variable ${CALLERID(num)} is only available in
Asterisk 1.2 and later. If you need to manipulate it in other ways, see
the section on String Handling Functions on the Asterisk variables
page - for example, to always strip the first digit or character off of
incoming Caller ID, you could probably use ${CALLERID(num):1} (adding
the :1 to return all characters AFTER the character in the first
position - this could also be used to strip a leading "+" if a provider
adds that).
Here's another example, in which digits are both removed and added - in the FreePBX forum,
colinjack wrote, "My SIP provider CallerID comes in the format
+44123456789 but my database uses 0123456789 - so I needed to remove
the '+44' and add a '0' to the callerid to allow it to query the user
database." And he added this to extensions_custom.conf to accomplish
this:
[from-trunk-custom]
exten => _X.,1,Set(CALLERID(num)=0${CALLERID(num):3:12})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)
Then he changed his sip trunk context statement to context=from-trunk-custom
Just in case anyone wonders, you can use the same custom context
(in extensions_custom.conf) for multiple trunks, as long as they
originally had the same "context=" destination. Or, if you need to make
different changes to the Caller ID from different trunks, then just
make multiple custom contexts in extensions-custom.conf, and change the
names slightly (e.g. you could call one from-trunk-add-0-custom and
another from-trunk-strip-2-custom, or whatever - just make sure to use
the same context name in the trunk "context=" line and in the header of
your custom context).
Finally, for those using naftali5's Dialplan Injections module,
you can place these code fragments in a Dialplan Injection instead of
extensions_custom.conf. Simply enter the lines beginning with the "Set"
or "Goto" command, like this:
Set(CALLERID(num)=0${CALLERID(num)})
Goto(from-trunk,${EXTEN},1)
Then note the number of the dialplan injection (it will be printed
in angle brackets next to the injection name in the list of
injections), and in your trunk use context=injection-number where number
is the number of the injection. For example, let's say you named the
injection as "Change Caller ID", and after you created it you saw this
in the right hand column: Change Caller ID <15> - in your trunk, you'd then use context=injection-15
- Printer-friendly version
- Login or register to post comments
bump
bump
Someone only wanted to add the 0 if they got a 9 digit CallerID
This is a reply to a comment that was apparently removed while I was in the process of leaving the reply, but basically the commenter wanted to add a leading "0" to the Caller ID only if the received Caller ID was exactly 9 digits long. What I had written in response to that was this:
Maybe this would work:
[from-trunk-custom] exten => _X.,1,GotoIf($[${LEN(${CALLERID(num)})} = 9]?9digits:not9digits) exten => _X.,n(9digits),Set(CALLERID(num)=0${CALLERID(num)}) exten => _X.,n(not9digits),Goto(from-trunk,${EXTEN},1)Note the above is untested (by me), but I think it would do what you want, which is to add the 0 only if you get a CallerID that is exactly 9 digits long. If my syntax is not exactly right, at least it might get you started in the right direction.
Would you please help me to fix it?
Hi wiseoldowl,
Sorry about that I removed my comment. I thought if I post at the wrong place?
I post my comment here again .
Thanks for your reply and I have copied your setting to my [from-trunk-custom]
When I called in from my cell phone it dropped after two or three rings that I
heard from my cell phone. In CLI I only got as below:
-- Executing GotoIf("SIP/192.168.8.252-088733c8", "1?9digits:not9digits") in new stack
-- Goto (from-trunk-custom,701,9)
asterisk1*CLI>
I have post my comment on trixbox froums for help:
http://www.trixbox.org/forums/trixbox-forums/help/how-change-incoming-ca...
Finally I have got it to work but I thought it's not good enough.
I would like to see if your setting is much better than mine, because what you thought
what I need.
Now a little change here,to add the 0 only if I get a CallerID that is 8 or 9 digits long.
Would you please help me to fix it?
I deeply appreciate your kindness.
Jack
How to change incoming caller ID?
I'm running trixbox 2.2.4 and it's working like a charm except incoming caller ID.
The incoming caller ID should be displayed in my country is as followers:
1)local caller ID displays seven or eight digits : ex. [2-8]XXXXXX or [2-8]XXXXXXX
2)long distance caller ID displays ten digits leading with 0 : ex. 0[2-8]XXXXXXXX or 0[2-8]XXXXXXX
3)cell phone caller ID also displays ten digits leading with 0 : ex. 09XXXXXXXX
4)international caller ID displays fourteen digits : ex. 00XXXXXXXXXXXX or whatever .
The incoming caller ID including 1)local and 4)international displays properly except
2)long distance and 3)cell phone.
My problem is the incoming caller ID including 2)long distance and 3)cell phone only
displays nine digits without the leading digit "0". Why the leading digit "0" is stripped
off? I cannot not do a proper callback if the leading digit "0" is missing.
I have followed the documentation above :
Edit etc/asterisk/extensions_custom.conf and add the following at the bottom of the file:
[from-trunk-custom]
exten => _X.,1,Set(CALLERID(num)=0${CALLERID(num)})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)
In that event all the incoming caller ID will be added the leading digit "0" to 1)2)3)4)
mentioned above. Although it will work for 2)long distance caller ID and 3)cell phone caller
ID, it will cause another problem because I don't need to add the leading digit "0" to 1)local
callerID and 4)international caller ID.
How can I change this? Would you please help me to solve it step by step?
Jack
bump
bump