Inbound routing based on CID

I have several inbound routes:

1
DID 31299123456
CID _X.
goes to ringgroup

8
DID Any
CID _X.
goes to extension 1060

9
DID Any
CID Any
goes to IVR

If someone calls without CID the call routes to 9, which is okay

If someone with CID calls to 31299123456 the call routes to 1, which is okay.
If someone else with CID calls to 31299123456 the call routes to 9, which is false.
The only difference i see is that the first ( good )incoming call has a CID in the form: 0643214321 and the second ( false ) incoming call has a cid +31687654321 ( coming from a different cell provider who probably routes the call through anothe country )

Good:

Executing [31299123456@from-sip-external:1] NoOp(“SIP/80.252.84.190-11b77820”, “Received incoming SIP connection from unknown peer to 31299123456”) in new stack
Executing [31299123456@from-sip-external:2] Set(“SIP/80.252.84.190-11b77820”, “DID=31299123456”) in new stack
Executing [31299123456@from-sip-external:3] Goto(“SIP/80.252.84.190-11b77820”, “s|1”) in new stack
Goto (from-sip-external,s,1)
Executing [s@from-sip-external:1] GotoIf(“SIP/80.252.84.190-11b77820”, “1?from-trunk|31299123456|1”) in new stack
Goto (from-trunk,31299123456,1)
Executing [31299123456@from-trunk:1] NoOp(“SIP/80.252.84.190-11b77820”, “Catch-All DID Match - Found 31299123456 - You probably want a DID for this.”) in new stack
Executing [31299123456@from-trunk:2] Goto(“SIP/80.252.84.190-11b77820”, “ext-did|s|1”) in new stack
Goto (ext-did,s,1)

Executing [s@ext-did:5] Set(“SIP/80.252.84.190-11b77820”, “CALLERID(name)=+31687654321”) in new stack

Bad:

Executing [31299123456@from-sip-external:1] NoOp(“SIP/80.252.84.190-11c68510”, “Received incoming SIP connection from unknown peer to 31299123456”) in new stack
Executing [31299123456@from-sip-external:2] Set(“SIP/80.252.84.190-11c68510”, “DID=31299123456”) in new stack
Executing [31299123456@from-sip-external:3] Goto(“SIP/80.252.84.190-11c68510”, “s|1”) in new stack
Goto (from-sip-external,s,1)
Executing [s@from-sip-external:1] GotoIf(“SIP/80.252.84.190-11c68510”, “1?from-trunk|31299123456|1”) in new stack
Goto (from-trunk,31299123456,1)
Executing [31299123456@from-trunk:1] Set(“SIP/80.252.84.190-11c68510”, “__FROM_DID=31299123456”) in new stack
Executing [31299123456@from-trunk:2] Gosub(“SIP/80.252.84.190-11c68510”, “app-blacklist-check|s|1”) in new stack
Executing [s@app-blacklist-check:1] LookupBlacklist(“SIP/80.252.84.190-11c68510”, “”) in new stack

“CALLERID(name)=0643214321”) in new stack

Your going to have to do some custom coding to create a custom context to strip the leading callerid. You might be able to do it with this unpublished, unsupported, beta-at-best module (if you find it useful, im sure a small bribe can get it in to the next version…)

BTW, the module is far from finished, and youll probably get error’s trying to install it from the FreePBX module admin. Instead, create a new directory under /var/www/html/admin/modules called setcid, manually un-tar (with winrar if your on windows) and copy the files over. Then return to the modual admin and install it from the list

Since upgrading to 2.5.X my inbound call routing is not working at all

Moshe thanks,

I’m a bit afraid to go playing with modules that are not finished as my wife doesn’t like it if we are inreachable again because i broke something. I had hoped to get callers without cid to an IVR as also asked in: http://freepbx.org/trac/ticket/2668. I think i’ve come some way, but i can’t find any info on how asterisk interpretes the "_X."
I will bribe you as soon as i have a good way to send callers without CID to an IVR without having to make 10 other inbound routes or manually change the extension.conf file.

henkiepenkie, can you show a bit of cli/log output for callers without cid? I’m pretty certain that your issues are trivial (well, there issues for you, but they should be easily solvable), as you can have inbound routes with callerid such as ANONYMOUS, UNKNOWN, OUT OF ARA, etc

Moshe, thanks again

This is a anonymous inbound call:

[Oct 19 13:26:58] VERBOSE[3682] logger.c: – Executing [31299123456@from-sip-external:1] NoOp(“SIP/anonymous.invalid-c0022360”, “Received incoming SIP connection from unknown peer to 31299123456”) in new stack
[Oct 19 13:26:58] VERBOSE[3682] logger.c: – Executing [31299123456@from-sip-external:2] Set(“SIP/anonymous.invalid-c0022360”, “DID=31299714048”) in new stack
[Oct 19 13:26:58] VERBOSE[3682] logger.c: – Executing [31299123456@from-sip-external:3] Goto(“SIP/anonymous.invalid-c0022360”, “s|1”) in new stack
[Oct 19 13:26:58] VERBOSE[3682] logger.c: – Goto (from-sip-external,s,1)
[Oct 19 13:26:58] VERBOSE[3682] logger.c: – Executing [s@from-sip-external:1] GotoIf(“SIP/anonymous.invalid-c0022360”, “1?from-trunk|31299123456|1”) in new stack
[Oct 19 13:26:58] VERBOSE[3682] logger.c: – Goto (from-trunk,31299714048,1)

My thought that if i use anonymous, i will also have to make a route for the others like “unknown” etc.

edited phonenumber

Try some sip debuging - there are providers who WILL provide callerid in some parts of the headers but not in other. Also, the dialplan show a generic no callid message. If you use the sip packets to set the callerid, you may be able to get a more specific “name” (such as ANONYMOUS)

sip set debug 5

mjh001,
You are attempting to hijack a thread about a specific caller ID detection issue, versus a “call routing issue” related to a upgrade.

Please go to the forums section and start a new thread.

I can confirm that. I can’t get any kind of inbound call routing (to any destination: callback, anouncement, voicemail) to work anymore since the upgrade.

The callerid is succesfully detected but the callflow does not care about the specified call routing…

Oops! Wrong thread indeed…sorry!

Moshe, thanks again.

I can filter on anonymous. That seems to work fine. ( see log of anonymous inbound call 2 messages up ) But what i want to achieve is this:
I’ve got 5 DID’s. One for each of the childeren, one for my wife and me and two in other places to play around with. I would just like to send anyone with no CID on any of those numbers to the same IVR. People that call directly - eg to my ip address with no CID also have to go to same ivr. If they use cid They are routed to the phone on my desk on the hours that i am not sleeping.
As far as i can see it everything works except that _X. doesn’t match with a CID that starts with a +

I used to do this in the way as described in http://freepbx.org/trac/ticket/2668 But as p_lindheimer says, I should be able to do it in the inbound routes. For as far as i can see now i have to make 7 different inbound routes for 5 numbers. That would mean 35 routes.

Don’t you have a brilliant Idea?

Henk

Well, back to the custom context thig then…

Thanks again.

I’ve tried everything now. including different combinations of these threads:
http://www.freepbx.org/support/documentation/howtos/how-to-change-incoming-callerid
http://freepbx.org/forum/freepbx/tips-and-tricks/changing-incoming-callerid
http://pbxinaflash.com/forum/showthread.php?t=921
http://pbxinaflash.com/forum/showthread.php?t=946

I will donate $ 50,00 if something like http://freepbx.org/trac/ticket/2668 gets into some update.

Henk