Two small improvements

Hello all,

I’ve been working recently on quite a complicated project that requires some complex routing and pattern matching between the PBX and 3 more systems.

I came across two issues, which from what I understood should be an easy fix…

The first issue is that we wanted to allow dialing different patterns in different IVRs, so we created a directory and tried adding a pattern. After testing, the dialplan is written that it tries to go to the actual pattern instead of the dialed extension.

[from-ivr-directory-4]
include => from-ivr-directory-4-custom
exten => 502,1,Macro(blkvm-clr,)
exten => 502,n,Set(__NODEST=)
exten => 502,n,Goto(from-internal,502,1)

exten => _41XX,1,Macro(blkvm-clr,)
exten => _41XX,n,Set(__NODEST=)
exten => _41XX,n,Goto(from-internal,_41XX,1)

So I created a feature request and submitted a PR that changes the dialplan to go to ${EXTEN} which ends up looking like this:

[from-ivr-directory-4]
include => from-ivr-directory-4-custom
exten => 502,1,Macro(blkvm-clr,)
exten => 502,n,Set(__NODEST=)
exten => 502,n,Goto(from-internal,${EXTEN},1)

exten => _41XX,1,Macro(blkvm-clr,)
exten => _41XX,n,Set(__NODEST=)
exten => _41XX,n,Goto(from-internal,${EXTEN},1)

The second issue is, that we want to be able to set the outbound caller ID that are routed to the other systems from a variable on the outbound route level. The variable would look like this:

${IF($["empty${myVar}"!="empty"]?${myVar}:8884441234)}

The problem is, that the outbound route Route CID field only accepts 40 characters.
So I created a feature request and submitted a PR that increases from 40 to 255 characters

I would love to see both features in FreePBX, or at least in edge so others can test as well.

This is my first and second PR ever to the FreePBX project, so please go easy on me… LOL.

Thanks


TL;DR

Two feature requests with PRs, I’d love to see in FreePBX.

First:
https://issues.freepbx.org/browse/FREEPBX-23693
https://git.freepbx.org/projects/FREEPBX/repos/ivr/pull-requests/38/overview

Second:
https://issues.freepbx.org/browse/FREEPBX-23697
https://git.freepbx.org/projects/FREEPBX/repos/core/pull-requests/493/overview

2 Likes

Update…

Both features are now in edge.
Core v15.0.22.20
Core v16.0.65.16
ivr v15.0.30
ivr v16.0.5

The main PSTN outbound route looks like this now:

The actual if statements:

${IF($["e${CUT(PJSIP_HEADER(read,X-CID),@,1):-10}"!="e"]?${CUT(PJSIP_HEADER(read,X-CID),@,1):-10}:${IF($["${LEN(${CALLERID(num)})}"!="10"]?8884440000:${CALLERID(num)})})}

Broken down:

  1. If the X-CID header is present, use the last 10 characters of the header’s user field as the caller ID.
  2. If the header is not present, then…
  3. If the current caller ID number length is less than 10 characters, then use their main phone number as the caller ID
  4. Assuming now that the original caller ID is valid, then use that as the caller ID.

So basically what happens is, if an internal user on another system reached FreePBX, there will be a X-CID header with their external caller ID so if the routing rules sends that number to the PSTN, the Outbound Route will change the caller ID to what was set in the X-CID header.
If an external incoming call is sent to another external number, then we will use the original caller’s caller ID.
If an internal FreePBX extension has no external caller ID then we will set the main number as the caller ID.

There’s probably a more elegant way to do that, but that is a one liner that works in the GUI…

Feel free to reply with any comments/suggestions/feedback

P.S. I know that officially, FreePBX is forwarding the original caller’s caller ID, but that doesn’t appear to be working even prior to this update.

Thanks

2 Likes