Extracting Inbound Caller ID from Remote-Party-ID Field

I’m working with a FreePBX system that is tied to a service provider which sends the Inbound Caller ID in a Remote-Party-ID field in the incoming INVITE messages. FreePBX is set up to use get the Inbound Caller ID from the From: field.

How can I set up FreePBX to extract the Inbound Caller ID from this Remote-Party-ID field, rather than the From: field?

I dont’ know a context that already has this, but you can extrapolate the method by looking at from-pstn-toheader

; from-pstn-toheader
; The context is designed for providers who send the DID in the TO: SIP header
; only. The format of this header is:
; To: <sip:[email protected]>
; So the DID must be extracted between the sip: and the @, which this does
exten =>  _.,1,NoOp(Attempting to extract DID from SIP To header)
exten =>  _.,n,gotoif($["${CHANNEL(channeltype)}"="SIP"]?SIP)
exten =>  _.,n,gotoif($["${CHANNEL(channeltype)}"="PJSIP"]?PJSIP)
exten =>  _.,n,NoOp(Unable to determine SIP channel type)
exten =>  _.,n,goto(from-pstn,${EXTEN},1))
exten =>  _.,n(SIP),Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
exten =>  _.,n(PJSIP),Goto(from-pstn,${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)},1)

It should only be necessary to enable “Trust RPID” in the trunk settings, tho i have replied with this advice in the recent past and was told it didn’t work for them.

1 Like

I tried putting trustrpid=yes in the inbound section of the trunk settings and this didn’t work.

The inbound/outbound thing is confusing. It is only really needed for the, deprecated, chan_sip driver, and even then it isn’t always needed. If the outbound section matches the IP address it may well be used for inbound calls. If you have both sections, you should include everything relevant to incoming calls in both.

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