Caller Name is set = to Number and set = to Trunk Name


I have a Raspberry Pi Zero with RasPBX with Asterisk 13.13.1 upgraded to 13.15.0 & FreePBX upgraded to . PSTN calls come in via an OBi110.

When a call comes into the OBi110 its Call History shows
Peer Name: blank
Peer Number: 012345678

In FreePBX there is a Trunk called =OBiTrunkSP2 and an Inbound Route that has a Custom Destination. In the Custom Destination context the command:

exten => 012345678,1,Noop(Incoming pstn call from ${CALLERID(all)})
gives Incoming pstn call from "0789123456" 0789123456

If a number is withheld the OBi110 shows
Peer Number: blank

and the context now shows
Incoming pstn call from "OBiTrunkSP2" OBiTrunkSP2

Whilst the first case is no problem (the PSTN does not send Caller Name), the second case is problematic if there are other different status from the PSTN (e.g. INTERNATIONAL, though I guess I can check for 00 if the number is provided)

How do I figure out if 1) OBi110 is wrongly sending or 2) Asterisk/FreePBX is wrongly receiving.

I’m sure that when I incorrectly had the Trunk context set to my custom code (rather that it set to from-pstn and using Custom Extension) that the caller ID was correctly shown as “” <0789123456> but I can’t find any log to prove it.

I’m reluctant to dump a whole log in this post but some things caught my eye:

>  Executing [[email protected]:2] Set("SIP/OBiTrunkSP2-00000019", "FROMEXTEN=unknown"  ) in new stack
>  Executing [[email protected]:3] ExecIf("SIP/OBiTrunkSP2-00000019", "11?Set(FROMEXTEN=OBiTrunkSP2)") in new stack

> Executing [[email protected]:5] ExecIf("SIP/OBiTrunkSP2-00000019", "1 ?Set(CALLERID(name)=OBiTrunkSP2)") in new stack

Thanks for reading

Because of how cnam works (rarely on CellPhones, Sporadically in the PSTN and invariably vague and dependent on being paid for :slight_smile: )

Thusly I suggest you should, as we all do, route incoming calls by CallerID(NUM) ONLY, worrying about callerid(NAME) will REALLY get you confused and just not work, as I mentioned in a previous post.

Again. ANY acceptable CallerID(NUM) from the PSTN will ALWAYS be within a regex of “^+?[0-9]{10,}” if you know what you are doing and have “private trunking” then you will know how to extend that. A good example is in /etc/asterisk/extensions.conf as [from-pstn-e164-us] , here the Callerid(NUM) is examined, chewed upon and then appropriately dispatched, it offers “normalization” to your locale, which will behoove you as you develop your outbound calling as appropriate to your locale.

If you are not a NANP dude as I suspect you are not, then you will need to modify, add and use the template [from-pstn-e164-us] to your newly scribed [from-ptn-e164-(your-iso-2-country)]

So for example ,I can deduce (perhaps incorrectly) that your CallerID(NUM) is 0789123456, so your are in the UK, your provider is using parochial UK numbering and it is a cell phone, in the e164 world that number would be +44789123456.

International metadata for Phone calling + (add it if not there)
UK = 44 (add it if indeed identified as a UK number)
^0 for parochial dialling (drop it)
^07 to identify a cell phone, but all the other national/premium/tollfree/personal prefixes will also fit here
Be aware of amy “short numbers” that your provider might recognize and pass, importantly in your case 999 and 112


If you remain confused, I suggest you read fully (and several times) the wiki which is linked to at the top of this post, , it works for most folk :wink:

Hello dicko. I fully understand that my PSTN is not providing Caller Name but as I tried to explain the PSTN does set the Caller Name to WITHHELD when the caller withholds their number. From other reading that it can also be INTERNATIONAL, UNKNOWN, and PAYPHONE. I’ll call this Call Type

My post was about the loss of the Call Type information between the OBi110 and Asterisk/FreePBX.


I’ve done a bit more experimenting. I changed the Trunk SIP Setting Context from from-pstn to from-pstn-temp

In extensions_custom.conf at the top I defined:
exten => 012345678,1,Noop(from-pstn-temp call from ${CALLERID(all)})
include => from-pstn

Now for a Withheld number the log shows:
from-pstn-temp call from “” < OBiTrunkSP2 >") in new stack

By the time the Inbound Custom Destination Context is triggered it has changed to:
Incoming pstn call from “OBiTrunkSP2” < OBiTrunkSP2 >) in new stack

This seems to show 1) early on FreePBX is not receiving the Caller Name (or it or Asterisk has changed it). 2) that FreePBX is setting Caller Name to Caller Number as shown by this log entry:

Executing [[email protected]:5] ExecIf(“SIP/OBiTrunkSP2-00000001”, “1 ?Set(CALLERID(name)=OBiTrunkSP2)”)

Note. Not only is the Trunk Name = OBiTrunkSP2 but also the username=OBiTrunkSP2 in the Trunk SIP Settings

I will next set Asterisk log to very verbose.


In the context ext-did-0002 is this line:

ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))

Which populates CALLERID Name with CallerID Number if the name is empty. I don’t think there is any way to override this.

I concur with @lgaetz however a custom context that handles (as the op suggests he is getting a call with a name but an empty number) to replace the empty number with the name before sending the call to from-trunk might be needed.

Thanks guys. I’ve now found posts from 2014 showing others had similar problems with their OBi110 suggesting the fault is with the OBI but if so, one might have hoped it would have been fixed by now. Now the OBi110 is end of life.

I found an inelegant solution - I can’t post links so search in UK VOIP Forums for “OBi110 - failure to show caller id” by mash on Sat 13th September 2014 at 00:17.

It uses an AIG Perl script that screen scrapes the OBi Call Status page (ugh) picking up the caller (peer) name and setting the variable CALLERID. When the PSTN does not have the number then the PSTN sets the name field to Withheld, International etc Unfortunately the script produces a noticeable time lag giving an extra ringing before the FreePBX script completes.

Anyone following that post needs to install both the included Perl packages, install the script in /var/lib/asterisk/agi-bin/ , make the script executable, and ensure owner and group are both set to asterisk. To call the script:

same => n,AGI(getcid.agi)

It was a pity that FreePBX confused the situation by setting a blank Caller Name to the Caller Number. As a former Database Administrator I cringe at such action. If there is no Caller Name (as with PSTN calls) then it’s much better to show that by leaving the field blank. Well that’s my view. End of rant!

Thanks for all your help. I think I’ve learnt enough together with your help to complete my FreePBX script.

Note the Issues link at the top of this page. I don’t know for what reason this was originally done (I can speculate), but feel free to make a case for change in a feature request. Maybe an Advanced Setting that overrides this.