Modify the Trunk "From User" based on extension number

Currently, all calls going out the same trunk use the same “From User” in the Advanced Trunk Settings. I need to modify on every call based on the extension, not based on the Trunk.

Using the [macro-dialout-trunk-predial-hook] macro, is there a way to modify the From in the Invite?

I know I can add new headers here, but I’m not sure about modifying just part of an existing header.

For example, I currently see this in an outgoing test call:

INVITE…
From: “” sip:[email protected];tag=0d7fa935-4b95-4c1f-a3af-18ac47ce6f11

I need to use [macro-dialout-trunk-predial-hook] to modify that to:

INVITE…
From: “” sip:[email protected];tag=0d7fa935-4b95-4c1f-a3af-18ac47ce6f11

By default, FreePBX sends the desired caller ID in the From header.
If From User for the trunk is left blank, this would be the Outbound CID for the extension, unless overridden by Outbound Route or Trunk settings.

Please explain what you are trying to put there and why.

Are you in a situation where P-Asserted-Identity or Remote-Party-ID are being misused for an account code, so you are misusing caller ID for the account code. If not, as already noted, you may be reading the provider’s documentation too literally and you should be using standard means of setting caller ID.

This is to be able to use Telnyx’s Dynamic 911 location (I think others, like Bandwidth, use a similar approach)

They specifically state that you need to add a new Geolocation header with a value that they provide. This value is different per-location (and therefore per-extension).

-AND-

They state you have to change the “FROM” to another value (that Telnyx also provides). This value is different per-location (and therefore per-extension).

Here is the example INVITE they provide, a direct copy and paste. The 2 items in bold are what changes based on extension. I have the Geolocation part, since that is a new header, that is not an issue.

INVITE sip:[email protected] SIP Proxy:5060 SIP/2.0
Via: SIP/2.0/UDP Telnyx Media IP:5060;branch=z9hG4bK-4126-1-0
From: sipp <sip:2d117a0a1dee74f1@Telnyx Media IP:5060>;tag=4126SIPpTag001
To: 933 <sip:[email protected] SIP Proxy:5060>
Call-ID: [email protected] Media IP
CSeq: 1 INVITE
Contact: sip:[email protected] Media IP:5060
Max-Forwards: 70
Subject: Performance Test
Geolocation:d4f52baed311ef95
Content-Type: application/sdp
Content-Length: 135

I would add a ‘key’ as AMPUSER/{ext}/geolocation in the sqlite3 database astdb with approprite values per extension, then write a custom context or macro to add a SIP header filled with the geolocation ‘value’ done with a dbget() call.

It appears that on an emergency (or emergency test) call, you don’t send any header with caller ID. If that is correct and intended, couldn’t you just put 2d117a0a1dee74f1 in the Emergency CID field for the extension, with From User left blank in the trunk, and it would just work?

Not a direct answer to what you are trying to do here but you should look at our 911 dynamic service we offer that has a module for FreePBX that makes it real easy to associate users with dispatchable locations and not have to modify anything.

Here is our wiki link on how this works and also includes all the required notifications for 911 calls. FreePBX & PBXact Automated Setup with Module

1 Like

That appears to be specific to ClearlyIP. I have nothing against Clearly, but it requires changing SIP providers Also, this eliminates the possibility of having a backup provider (non-Clearly) as well.

If that is correct and intended, couldn’t you just put 2d117a0a1dee74f1 in the Emergency CID field for the extension, with From User left blank in the trunk, and it would just work?

I actually tried that first but it showed up like:

From: “2d117a0a1dee74f1” sip:sip.telnyx.com;tag=dbdfbc4e-4a37-41f7-b770-c43e1a7c9ef1

because it isn’t numbers it thinks it is the friendly name.

But, you saying that made me try it again, this time putting <2d117a0a1dee74f1> (with the pointy brackets)… and it worked!

From: sip:[email protected];tag=6df71680-784f-4229-9121-df766b0df2c4

Thank you thank you!!!

No you don’t have to switch your trunking to us. You can move your 911 only to us. Anyways was just posting that we have a solution in FreePBX for this that does not require and custom configs or hoping your changes always work since 911 must always work and a update of something in asterisk or FreePBX doesn’t break it.

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