How To: effect per-call CIDblocking (PRIVATE/HIDDEN) on outbound calls, with FreePBX v15 and VoIP.ms

configuration
Tags: #<Tag:0x00007fb47c47bd18>

(POTS Head) #1

(aka: anon caller ID, anonymous CID, blocked caller, blocked CID, private caller, private CID, *67, #31#, *81)

My situation:

  • I seek to have per-call CIDblocking effected on outbound calls, de/activatable via CLASS codes (aka STAR-codes)

  • so, if I dial a number straight up, it AUTOMATICALLY places the ‘*67’-style CID-block on this outbound call

  • alternatively, if I want to PROVIDE my CID to my destination, then I prefix the dialed num with *67 (or even *31#)

  • while I’m there: if I dial a 7-digit phnum then automatically prefix my AreaCode to the phnum (replace ‘NPA’ with your local areacode in DialPatterns below)

 

Problem observation wrt CIDhide:

  • In FreePBX, if one sets the HideCallerID flag
    (via EditTrunk/Tab=General/HideCallerID)
    this seems to just set the CID to be:
             “hidden” <>
    but… this conflicts with VoIP.ms’ requirement that the
    proper CID be provided to VoIP.ms at time of call placement
    (i.e. the proper number gets placed between <> chars)

  • In response, in order to effect CIDblocking (aka *67-dialing) one must:
        - populate CID field with sufficient info
          (esp phnum) to keep VoIP.ms happy, and
        - at a ‘low-level’ set the ‘withhold-CID’ flag for the call

Below sol’n tested as working with Bell Canada (Wireless) as term carrier, and ‘Private Caller’ (or maybe it was ‘Private Number’) came up as both CIDnumber and CIDname, using FreePBX v15.0.17.24, with Asterisk v16.11.1.

================================================================================================
The TL;DR sol’n:

- Using sub-accounts on VoIP.ms create one each of a subaccount for
  CIDshow and CIDhide calls; set each as DeviceType=Asterisk & CIDnumber=IuseSystemCapable...
- using DialPatterns on OutboundRoutes we route calls to one or the
  other of a Trunk designated for CIDshow, or CIDhide, calls
- each of the two Trunks attaches to a subaccount: CIDshow or CIDhide
- we set the CID on the CIDshow Trunk to be: "real_name" <my_10_digit_phnum>
- we set the CID on the CIDhide Trunk to be: "private" <my_10_digit_phnum>
- in /etc/asterisk/extensions_override_freepbx.conf we add:
    [macro-dialout-trunk-predial-hook]
    exten => s,3,ExecIf($[ "${CALLERID(name)}" = "private" ]?Set(HASH(__SIPHEADERS,Privacy)=id))
    exten => s,5,MacroExit()

================================================================================================

More verbosely…

What happens below is that with an outbound route dedicated
(by way of using DialPattern matching) to CIDhide calls, we’ll
send the calls out via a Trunk dedicated to CIDhide calls.
This trunk has its CID setup with a ‘triggering’ name
(“private”), which gets matched in code that is hooked into the
predial context, and where the ‘withhold-CID’ flag then gets
activated.

=============
Step 1:

    On VoIP.ms, for each of the two subaccounts (CIDhide and CIDshow):
                Device type: Asterisk, IP PBX, Gateway or VoIP Switch
            CallerID Number: I use a system capable of passing its own CallerID

    (Strictly speaking one does not need separate sub-accounts but
     it helps with call segregation [accounting] at VoIP.ms' end.)

=============
Step 2:

    ========================================================
    Prepare FreePBX Route & Trunk for CIDshow...
    ========================================================
        - In FreePBX, create a trunk for CIDshow calls,
          named VoIP.ms####_CIDshow; populate PJSIP settings

        - In FreePBX, create an OutboundRoute for CIDshow calls,
          named ####_CIDshow_*67; populate DialPatterns as follows:
            ===============================================================
            PREPEND     PREFIX      MatchPattern        CallerID
            ===============================================================
                        *31#        1nXXnXXXXXX
                        *31#        n11
                        *31#        nXXnXXXXXX
            NPA         *31#        nXXXXXX
                        *67         1nXXnXXXXXX
                        *67         n11
                        *67         nXXnXXXXXX
            NPA         *67         nXXXXXX
            ===============================================================
            RouteSettings/TrunkSequenceForMatchedRoutes: VoIP.ms####_CIDshow
            ===============================================================

        - In FreePBX, for trunk named VoIP.ms####_CIDshow - make sure it's working with the O/B route

    ========================================================
    Prepare FreePBX Route & Trunk for CIDhide...
    ========================================================
        - In FreePBX, create a trunk for CIDhide calls, named VoIP.ms####_CIDhide; populate PJSIP settings

        - In FreePBX, create an OutboundRoute for CIDhide calls, named ####_CIDhide_*67; populate as follows:
            ===============================================================
            PREPEND     PREFIX      MatchPattern        CallerID
            ===============================================================
                                    1nXXnXXXXXX
                                    n11
                                    nXXnXXXXXX
            NPA                     nXXXXXX
            ===============================================================
            RouteSettings/TrunkSequenceForMatchedRoutes: VoIP.ms####_CIDhide
            ===============================================================

        - In FreePBX, for trunk named VoIP.ms####_CIDhide - make sure it's outdialing with the O/B route

        ==================================================================
            In FreePBX, for the CIDhide Trunk:
            -----------------------------------
                {tab=General}
                        Hide CallerID=No
                    Outbound CallerID="private" <your_10_digit_phnum>
                          CID Options=Force Trunk CID
        ==================================================================

=============
Step 3:

    Into this file:
         /etc/asterisk/extensions_override_freepbx.conf
    we'll insert the secret sauce:
        [macro-dialout-trunk-predial-hook]
        exten => s,1,NoOp(***** EnforceCIDblock-BEGIN [SuperVerbose] ***** EXTEN=${EXTEN} CIDnum=${CALLERID(number)} CIDname=${CALLERID(name)})
        exten => s,2,ExecIf($[ "${CALLERID(name)}" = "private" ]?NoOp(***** EnforceCIDblock-CIDname [Verbose] Maybe matched - check for 0/1 before NoOp <-------)
        exten => s,3,ExecIf($[ "${CALLERID(name)}" = "private" ]?Set(HASH(__SIPHEADERS,Privacy)=id))
        exten => s,4,NoOp(***** EnforceCIDblock-END [SuperVerbose] ***** )
        exten => s,5,MacroExit()

=============
Step 4:

    Activate changes in Asterisk by way of:
        asterisk -rx 'dialplan reload'

=============
Step 5:

    - reset logfile
       e.g.: cat /var/log/asterisk/full >> /var/log/asterisk/full-`date +"%Y%m%d"`
             printf "" > /var/log/asterisk/full
    - test as desired
    - locate activity in logging via:
        grep -iE --color=always "Verbose\]" /var/log/asterisk/full
    - profit!

(Lorne Gaetz) #2

It’s not wrong, but it’s conventional to put user defined dialplan in extensions_custom.conf. The override file is intended for existing generated dialplan that you want to modify.


(Maskicom) #3

I do need to do something similar with another carrier but solution. I’ll let you know my findings.


(POTS Head) #4

[quote=“lgaetz, post:2, topic:73783, full:true”]

It’s not wrong, but it’s conventional to put user defined dialplan in extensions_custom.conf. The override file is intended for existing generated dialplan that you want to modify.[/quote]
As I understand things:


(POTS Head) #5

AIUI:
- the sensible place to activate the withhold_CID flag is in [macro-dialout-trunk-predial-hook]
- the only place to do this is via extensions_override_freepbx.conf

Am I wrong on either point?


#6

Agreed.

I disagree. The default (empty) macro is defined in extensions.conf (not in extensions_additional.conf), so it can be overridden in extensions_custom.conf.

Except for some unusual applications, I also disagree with the premise. IMO, ‘anonymous’ calls are much more likely to be mishandled (from either party’s point of view) than calls from a number that the called party does not recognize. Also, anonymous calls give very little privacy, because many systems will display hidden numbers.

For example, a doctor calling anonymously with important medical information may not get through, but if he displays the main number of the hospital, he will likely succeed.

IMO, if a business wants to hide an agent’s number, depending on the situation, they should show the main company number, a DID with an announcement “this number does not accept incoming calls”, or a ‘generic’ number of their provider (available from Callecntric, Skype, Google and others).

DIDs cost almost nothing and having numbers where some privacy is desired is very easy. For example, I have a number used only for Craigslist listings.


(Dave Burgess) #7

In my experience, this solution actually provides a better outcome and experience for the calling party both in terms of returned calls and in getting calls answered once they are dialed. I work with a couple of call centers and I’ve set both of them up with “admin” numbers that start out with a “thanks for calling us back. We are trying to reach you about your car’s extended warranty …” (just kidding, but you get the idea). I tell all of my telephony customers to always block and not answer ‘private’ numbers so it makes sense that I would always provide a workable CID.


(Tom Ray) #8

All in time for STIR/SHAKEN, too.


(POTS Head) #9

Oh, I did not know that. My (very superficial) reading had led me to believe that defining the macro a second time would cause an error.

Well, one can make it default to CIDshow… I just happen to prefer CIDhide.

And yeah, often doing the right thing (vigourously attempt to protect my privacy) is to not do the easy thing.

Heh, bad example.

With COVID going on, here in Ontario most Dr appts are by phone. Many docs are working from home. My doc calls me as PRIVATE, likely calling from her homephone or personal cell. Since the calls are scheduled tho, one knows to accept.

OTOH, I don’t mind leaving a voicemail and receiving a callback.

Thx again for the pointer to editing instead the _custom file.


(POTS Head) #10

I guess that’s what I got nailed by?!

Prior to implementing this fix, and up to end of March, all I had done to implement CIDhide in FreePBX was just activate, in Trunk Settings, the ‘Hide CallerID’ setting.

FWICT that would:
- place “hidden” as CIDname
- leave the CIDnum blank

(In fact if one deactivated the ‘Hide CallerID’ setting and just changed the CIDname field to say ‘hidden’ [and saved the settings], when one refreshed the page the ‘Hide CallerID’ setting was activated.)

Having a blank CIDnum field seems to violate the new rules about proper CIDnum being provided and so I guess that VoIP.ms just recently got around to enforcing things at their end.

Maybe an RFE for FreePBX is to make handling this ‘privacy’ flag, that effects CIDhide, a GUI-accessible option?!


(system) closed #11

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