Route Anonymous Calls Separately From Normal Calls

Hello,

I’ve run into an issue where I’d like calls marked as anonymous or no caller ID to be routed to a separate area than calls that display their phone number.
This is because our system needs to log their phone number in order for some systems to operate.

As of such, I’d like callers who have not displayed their number to be played a pre-recorded message and then hung up on.

If anyone has a solution to this I’d be greatly thankful.

Thanks!

You can create another inbound route that looks for the CID ‘anonymous’, ‘blocked’ or ‘private’ and send the destination to terminate call.

You may need 3 individual inbound routes to take them all in, it depends on what called ID they usually show up in your system.

Or, set up your regular Inbound Route to have CallerID Number
_X.
and then create an Any (Caller ID Number left blank) route to catch anything that doesn’t begin with a digit.

@Stewart1
Unfortunately, it doesn’t look like this works.
View this image on the config that I set and let me know if I’ve made a mistake:

Thanks for your reply!

You missed the . at the end.

The forum does a bad job of showing inline code blocks.

But see how it was all in the grey background?
image

Ah, thanks!

Sorry, I thought that the dot was the end of the sentence!

I’ll update it and see what happens.

Hiya,

I tried the setup above. Normal calls ended up being sent to the wrong destination.

Here is the image:

The one with the time conditions is where I want calls to go to.

Thanks.

Perhaps your onymous calls start with a + sign, in which case they won’t match the X and you should use
_+X.
instead.

If that’s not your issue, paste a log of a normal call not matching the time condition route.

Didn’t look like it worked.
Real calls still went to the wrong destination.

Not sure how to get call logs. Also, I’m having an issue where it’s hard for me to mimic a withheld call because my number provider somehow still manages to find the number haha. That’s why its taking long for me to test it out.

https://wiki.freepbx.org/display/SUP/Providing+Great+Debug#ProvidingGreatDebug-AsteriskLogs-PartII

On my mobile (T-Mobile, Google Pixel 4a 5G), I can call anonymously by dialing with *67 in front of the number, or by going to Phone → Settings → Calling Accounts → T-Mobile → Additional Settings → Caller ID and choosing Hide Number.

Of course, if your trunking provider supplies P-Asserted-Identity on blocked calls and you have custom dialplan to fish that out, then your number will still be displayed. But if that’s the case, you should see very few ‘anonymous’ calls (only those from spammers, etc.)

Yeah, it’s a strange one! I’ve turned it off in my IOS settings and it shows as withheld to everyone I dial apart from my own number haha!

I’m not sure if this is what you’re after but its what’s showing in my asterisk logs:

Logs
/var/log/asterisk/full:[2021-08-24 18:37:08] VERBOSE[19414][C-000061f3] pbx.c: Executing [s@ext-did:21] Set("PJSIP/Dial_9_Inbound-00006279", "__CRM_LINKEDID=1629830228.27285") in new stack
/var/log/asterisk/full:[2021-08-24 18:37:09] VERBOSE[19414][C-000061f3] pbx.c: Executing [s@macro-user-callerid:1] Set("PJSIP/Dial_9_Inbound-00006279", "TOUCH_MONITOR=1629830228.27285") in new stack/var/log/asterisk/full:[2021-08-24 18:37:35] VERBOSE[19414][C-000061f3] pbx.c: Executing [s@crm-hangup:4] NoOp("Local/FMGL-2001@from-internal-000002d1;1", "MASTER CHANNEL: 1629830229.27288 = 1629830228.27285") in new stack
/var/log/asterisk/full:[2021-08-24 18:37:35] VERBOSE[19429][C-000061f3] pbx.c: Executing [s@crm-hangup:4] NoOp("PJSIP/2001-0000627b", "MASTER CHANNEL: 1629830236.27291 = 1629830228.27285") in new stack
/var/log/asterisk/full:[2021-08-24 18:37:35] VERBOSE[19429][C-000061f3] pbx.c: Executing [s@crm-hangup:4] NoOp("PJSIP/2001-0000627c", "MASTER CHANNEL: 1629830236.27292 = 1629830228.27285") in new stack
/var/log/asterisk/full:[2021-08-24 18:37:35] VERBOSE[20278][C-000061f3] pbx.c: Executing [s@crm-hangup:4] NoOp("Local/FMPR-2000@from-internal-000002d0;1", "MASTER CHANNEL: 1629830229.27286 = 1629830228.27285") in new stack
/var/log/asterisk/full:[2021-08-24 18:37:43] VERBOSE[20279][C-000061f3] pbx.c: Executing [s@crm-hangup:4] NoOp("PJSIP/2000-0000627a", "MASTER CHANNEL: 1629830229.27290 = 1629830228.27285") in new stack
/var/log/asterisk/full:[2021-08-24 18:37:43] VERBOSE[19414][C-000061f3] pbx.c: Executing [s@crm-hangup:4] NoOp("PJSIP/Dial_9_Inbound-00006279", "MASTER CHANNEL: 1629830228.27285 = 1629830228.27285") in new stack

The log for a call is typically a few hundred lines. Select all the entries for the incorrectly routed call, paste it at pastebin.freepbx.org and post the link here.

Hiya,

I believe that this is what you are after:

https://pastebin.freepbx.org/view/fccfbbf8#L9

Thanks for all your help!

I’m suspecting that there is a quirk or bug associated with routes with DID set to Any.
See whether setting CID Priority Route for the time condition route causes it to take that path.

If not:
The called number on your logged call shows as 0 – do you know what causes that? I would expect 10 or 11 digits there.

How many DIDs do you have? Are they associated with multiple inbound trunking providers?

The trunk connects from 0@serverip, that may be what you’re meaning. Just how dial9 works.

Also, the caller number was obfuscated with NPANXXXXXX.

We don’t have any DID’s set in the routes along with only one trucking provider. Note, that they’re UK numbers which tend to start with 0 or +44.

I assume that you mean connects to 0@serverip (that is what is in the SIP URI).
If setting CID Priority Route doesn’t help, try setting DID Number for both routes to 0
Or, setting the Context for the trunk to from-pstn-toheader will likely cause the actual dialed number to appear as the DID.

RIght,

Looks like setting it to “_X.” and setting the CID priority to the time conditions route worked. I’ll need to get someone to test it for the withheld route and probably international calls to make sure those still work.

Will update here once I get both of those tested.

Thanks!

Just got it tested. Looks like its working for a withhold number!

Okay, I got an international caller to call. They were directed to the incorrect route.
To be precise a Canadian number.

Calls starting with a ( or + are subject to that from what I can see.

Can this be resolved?