Passing original CallerID to external number in FM/FM

edit: redaction on a screenshot

FreePBX Version 15.0.16.81
Asterisk Version 16.15.0
PJSIP

I realize this topic has been covered multiple times. I also feel like my situation is unique because my sip trunk provider claims we are their first FreePBX system to use them. The provider is Momentum (US) via our local utility provider.

Original problem began when COVID hit the US and employees went to remote work. We turned on FM/FM for those employees and the complaints came rolling in that they only knew it was a work call because the caller ID was their office DID. They (rightfully so) wanted to know who the original caller was. I have been working with my provider to find a solution and they, unlike other providers, require the P-Asserted-Identity to be sent as sip:[email protected] and then it would pass the original CID. We spun up a new VM with a fresh install of FreePBX and configured it the same but with a test trunk and three DIDs.

That’s where I started down the rabbit hole of using various methods:

Provider suggested the following:
In FreePBX system manually edit/create /etc/asterisk/extensions_override_freepbx.conf
in other asterisk systems edit/create /etc/asterisk/extensions_custom.conf

Add:

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Insert P-Assert Header for External DID CID)
exten => s,n,SipAddHeader(P-Asserted-Identity: sip:[email protected])

Based on reading a ton of threads on this, isn’t the code above an “easy” fix for Chan_sip but not a solution for PJSIP?

Here are my trunk settings:

Screenshot%202020-12-16%20172820

Test call placed from external number to a DID. Inbound route sends to extension with FM/FM active using ringallV2-prim ring strategy. Call rings for two seconds before attempting my cell phone 733XXXX. The provider then rejects the call to my cell phone. This is with no additions to either conf file above. This is also with blank CID fields at the extension level so it should send the PAI using the main trunk…

Searchable strings that may help you in the pastebin (501358XXXX and 733XXXX).

Here is the pastebin from that test call: Automatic Pastebin from Sangoma OS 7 - FreePBX Pastebin

I’m sure I’m leaving something out but this community has helped me and my colleagues on multiple occasions so I know someone can again, this time on my post and not another person’s post.

TIA,

Sean

Just went thru this yesterday with someone else.

[macro-dialout-trunk-predial-hook]
exten => s,1,GoSub(func-set-sipheader,s,1(P-Asserted-Identity,sip:[email protected]))
exten => s,n(done),MacroExit()

You’ll want to disable the send rpid option for the trunk config in the GUI, and use the dialplan above to add it. That will add the header on all outbound calls, but if you have multiple trunks, you will want to add logic to only apply to the trunk that needs it. There is a post here to determine the trunk name of an outbound call: Custom SIP header on outgoing calls

3 Likes

Thank you, @lgaetz! That did the trick. I tried variations of the [macro-dialout-trunk-predial-hook] but never set Send RPID/PAI to none.

1 Like

I’d like to comment onto this as well, since our provider we use for our main SIP lines also switched to Momentum. We had the same issue and Lorne was able to guide us to the same solution. In case others happen to run into this I had the following settings in order for PJSIP to work:

PSJIP Settings -> General Tab

  • Username = <10-digit hook number>
  • Secret = Password
  • Authentication = Outbound
  • Registration = Send

PJSIP Settings -> Advanced

  • Contact User = 10-digit hook number (this may not be needed)
  • From Domain = mymtm.us
  • Client URI = sip:<10-digit hook number>@mymtm.us
  • Server URI = sip:<10-digit hook number>@[direct.mymtm.us]
  • Send RPID/PAI = No
  • Trust RPID/PAI = No

In order to pass the PAI to Momentum, I had to add the following to Extension_custom as noted above:
[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
exten => s,n,ExecIF($["${OUT_${DIAL_TRUNK}SUFFIX}"!=""]?Set(trunk_name=${OUT${DIAL_TRUNK}SUFFIX}):Set(<trunk_name>=${OUT${DIAL_TRUNK}}))
exten => s,n,Noop(Trunk Name: ${trunk_name})
exten => s,n,GoSubIf($["${trunk_name}"="@momentum_trunk_name"]?func-set-sipheader,s,1(P-Asserted-Identity,sip:[email protected]))
exten => s,n(done),MacroExit()

(Note: the momentum_trunk_name and the 10digithooknumber are variables that you would need to replace)

Another note is that if you use the FQDN, you may need to add the following:
Config Edit -> sip_general_custom.conf

  • srvlookup=yes
  • register_retry_403=yes

I hope this helps someone else in the future

Chris

1 Like

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