Changing inbound CID name and num from "unknown" to "0" via custom dialplan context

Dear fellow freePBX users,

I just want to change the incoming CID to “0” if CID name or num = “unknown”. This should be quite simple, but I’m stuck figuring out how and where to inject my three lines.

For now I’m aware of these two possibilities

  1. recommended: add custom context and set this in trunks settings
  2. use auto generated custom context which is automatically included (from-trunk-sip-voipGwName-custom)

Going with the first solution I created a custom context “from-trunk-unknown” in extensions_custom.conf:
[from-trunk-unknown]
exten => _.,1,ExecIf($[ “${CALLERID(name):0:7}” = “unknown”]?Set(CALLERID(name)=0))
exten => _.,n,ExecIf($[ “${CALLERID(num):0:7}” = “unknown”]?Set(CALLERID(num)=0))
exten => _.,n,Goto(from-trunk,${EXTEN},1)

I set this in my trunk incoming settings:
USER Context: inbound
USER Detail
secret=*****************
type=peer
canreinvite=yes
context=from-trunk-unknown
dtmfmode=rfc2833

When I Apply changes the context “from-trunk-unknown” is loaded (fwconsole and full log show that), but it is never used. Inbound calls start in context “from-trunk-sip-voipGwName” and then continue in “from-trunk”.

Any help on how to get this working is highly appreciated.

Also I wonder if the User Context “inbound”, which seems not to be required in our setup, is causing
trouble.

Cheers,
Marcus

FreePBX 13.0.190.7

It looks like your Trunk isn’t pointing your calls to the right context. The trunk is usually associated with a specific provider or IP address, so you need to check those first.

Normally, when a call comes in, it’s sent from the trunk to the “standard” inbound route processing chain (from-internal, from-pstn, etc.) and matched up with one of your defined inbound routes. Once there, the “best match” for DID and CID are matched, and if no matches are found, the call is routed to the “ANY/ANY” route. The context on the matched (or unmatched) inbound route determines how the call is routed.

it looks like your trunk is pointing your calls to a custom route instead of the default “from-whatever” context, so your context is getting ignored.

Show us a log of the failed call.

Is this a system you built or did you inherit it?

I just figured out, that I have to set the trunks context in trunk sip settings outgoing PEER details. This way it is used as expected. Full log follows, “555” is not the real EXTEN

[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Executing [555@from-trunk-sip-berofixPRI-unknown:1] ExecIf(“SIP/berofixPRI-000220d2”, “0?Set(CALLERID(name)=0)”) in new stack
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Executing [555@from-trunk-sip-berofixPRI-unknown:2] ExecIf(“SIP/berofixPRI-000220d2”, “0?Set(CALLERID(num)=0)”) in new stack
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Executing [555@from-trunk-sip-berofixPRI-unknown:3] Goto(“SIP/berofixPRI-000220d2”, “from-trunk-sip-berofixPRI,555,1”) in new stack
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Goto (from-trunk-sip-berofixPRI,62882416,1)
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Executing [555@from-trunk-sip-berofixPRI:1] Set(“SIP/berofixPRI-000220d2”, “GROUP()=OUT_2”) in new stack
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Executing [555@from-trunk-sip-berofixPRI:2] Goto(“SIP/berofixPRI-000220d2”, “from-trunk,555,1”) in new stack
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Goto (from-trunk,555,1)
[2019-03-13 14:30:14] VERBOSE[25457][C-00010ac6] pbx.c: Executing [555@from-trunk:1] Set(“SIP/berofixPRI-000220d2”, “__DIRECTION=INBOUND”) in new stack

Unfortunately the rewrite of “unknown” to “0” doesn’t work. So now I gotta debug my two lines, see what is the incoming CALLERID(name) and CALLERID(num) actually.
Earlier we were using inbound routes pointing to Ring Groups and within dialparties.agi CALLERID(name) and CALLERID(num) were “unknown”. That’s why I’m checking for that

EDIT: after using
exten => _.,1,Log(NOTICE,Incoming call CID name = ${CALLERID(name)})
exten => _.,n,Log(NOTICE,Incoming call CID num = ${CALLERID(num)})

Then I knew that those variables were just empty and I had to check for that
exten => _.,n,ExecIf($[ “${CALLERID(name)}” = “”]?Set(CALLERID(name)=0))
exten => _.,n,ExecIf($[ “${CALLERID(num)}” = “”]?Set(CALLERID(num)=0))

Problem solved. Thanks for the hints and lending an open ear/eye :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.