How to change From Name in SIP-Invite

Hi,

how can I change:

From: <sip:alice to
From: Bob <sip:alice

In SIP-Invite. We are using PJSIP for this trunk and this “Message” should be Display to every extern called party.

Thank you

Frank

Is this for outgoing or incoming?

Can you please share a call trace via pastebin? Providing Great Debug - Support Services - Documentation

Neither of these are valid. If you meant:

From: Bob <sip:[email protected]>;tag=99999999

Bob is the caller ID name. Note that most providers, these days, will insist on alice being either the account name or one of your incoming phone numbers (depending on whether they use it for identification or caller ID.

I don’t think many providers will actually use the caller ID name.

I’m not 100% sure if Bob is still taken from the caller ID information when Alice is set using “from user”, and this may depend on the channel driver, which you didn’t identify.

If this trunk is for calling PSTN numbers via a commercial provider, be aware that in most countries, including Germany, the display name field of From or PAI is ignored. If you are calling e.g. Canada, and Outbound CallerID for the trunk is set to
"Frank" <+496126234567>
then Frank will likely be displayed on the called phone. You can also pass variable data by setting Outbound CID for the extensions.

If this is for an amateur radio application, please provide details.

Thank you for your replies!

No it’s not an amateur radio aplicaion :slight_smile: But 6126 is the right area code :wink:

We are using FreePBX for alltering several technicians depending on a calendar.
So we want to pass the calling Party ID to the technician (that’s working fine), If he’s unavailable he could call back, but to show the technician that the call has been made “through” the hotline we want to display an additional message on outgoing calls.

From: HOTLINE <sip:[email protected]>;tag=99999999 would be fine!

We are using easybell and their support statet that if we would pass any From “text” they would deliver this text to the other providers.

Wenn Ihr Endgerät im INVITE in dem From-Display-Part einen Namen überreicht, übergeben wir diesen an den Zielanbieter, der dies ebenfalls optional an den Zielteilnehmer weitergeben kann.

best regards

Frank

They may pass the text to the other providers, but if that provider were, British Telecom, in the UK, it would not be passed to their customer.

Also the ability to pass an arbitrary caller ID through, back onto the public network, is becoming very limited, as regulators crack down on telephone identity fraud. In the US, the best you can hope for is that the caller ID is marked as unverified, which may cause many downstream providers to suppress it completely, and consumers will learn to read it as meaning phone spam.

I have a feeling that you will need to provide custom dialplan, as I’m not sure that FreePBX can set caller ID name, but lead caller ID number untouched.

In raw Asterisk, you can set it, independently, by using Set(CALLERID(name)=HOTLINE).

(I think identity fraud (e.g. bank or governmental numbers) is the main driver for the regulators, but a secondary one is to prevent evasion of junk caller filters, and their use of random numbers local to the callee to make the call appear to be from someone known.)

This is what I did before:

exten => s,n,ExecIf($[“${CALLERID(number)}” = “+496198xyz”]?Set(CALLERID(all)=“Hotline” <06198xyz>))

But did not work either: From the FREEPBX wiki
Customize+outgoing+caller+name+and+caller+ID

sorry I can’t enter LINKS here

Whole Macro:

- Executing [s@macro-dialout-trunk:21] Macro("Local/01511zzzz@from-internal-00000012;2", "dialout-trunk-predial-hook,") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("Local/01511zzzz@from-internal-00000012;2", "CUSTOM: calleridall is "" <+496198xyz>") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:2] NoOp("Local/01511zzzz@from-internal-00000012;2", "CUSTOM: calleridnumber is +496198xyz") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:3] ExecIf("Local/01511zzzz@from-internal-00000012;2", "1?NoOp(CUSTOM:Setting Caller ID override for source +496198xyz)") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:4] ExecIf("Local/01511zzzz@from-internal-00000012;2", "1?Set(CALLERID(all)="Hotline" <06198yzx>)") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:5] ExecIf("Local/01511zzzz@from-internal-00000012;2", "0?Set(CALLERID(name)="Hotline")") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:6] MacroExit("Local/01511zzzz@from-internal-00000012;2", "") in new stack

That example confuses the issue by modifying the caller ID number at the same time, to convert from international to local format. That may well not be the right thing to do; the provider may only accept the format they used for the incoming call. I’d suggest just setting the name is better.

Are you sure that the INVITE doesn’t include the name, but it is being lost downstream?

Are you sure that the caller ID really is exactly “+496198xyz”?

What does the full log (make sure verbosity is at least 3) when this code is executed?

That’s a good question up to now I did not mange to see the SIP Invite package. Any hints to have it loged on the server?

asterisk -rvvvvvv is that enough "v" ?

I took this example from the wiki :slight_smile:

; Customization: Add a trunk predial hook to examine the outbound caller ID number and set the
;   outbound caller ID name based on the number (a workaround for a foreign PBX that cannot set the caller ID name string)
[macro-dialout-trunk-predial-hook]
; add log output to show outgoing caller ID information before any changes are made
;  note: don't comment out the first line without modifying the new actual first line of code to be sequence number 1
exten => s,1,NoOp(CUSTOM: calleridall is ${CALLERID(all)})
exten => s,n,NoOp(CUSTOM: calleridnumber is ${CALLERID(number)})
; test number case for debugging: override outgoing caller name and caller ID number for calls set to have the outgoing caller ID number to 555-555-1212 (remove comments to enable)
;;exten => s,n,ExecIf($["${CALLERID(number)}" = "+15555551212"]?NoOp(CUSTOM: Setting Caller ID override for source ${CALLERID(number)}))
;;exten => s,n,ExecIf($["${CALLERID(number)}" = "+15555551212"]?Set(CALLERID(all)="Test Number" <5555551212>))
; branch office location 1: override outgoing caller name and caller ID number for calls set to have the outgoing caller ID number to 519-123-4567
exten => s,n,ExecIf($["${CALLERID(number)}" = "+15191234567"]?NoOp(CUSTOM: Setting Caller ID override for source ${CALLERID(number)}))
exten => s,n,ExecIf($["${CALLERID(number)}" = "+15191234567"]?Set(CALLERID(all)="Branch Office" <5191234567>))
; default case for the main office: override outgoing caller name and caller ID number for calls set to have the outgoing caller ID number to nothing to be the main office caller ID name and number
exten => s,n,ExecIf($["${CALLERID(number)}" = ""]?Set(CALLERID(all)="Main Office" <5192345678>))
; exit back
exten => s,n,MacroExit()

Use the CLI command “pjsip set logger on”, or, if using the deprecated channel driver, “sip set debug on”. You can also use sngrep at the Linux shell level.

That example does more than change the caller name, for a small number of specified callers; it also changes the format of the caller number. There is no explanation of why it does the latter, and it may well break things.

Okay, here we go.
We use clip no screening to provide different numbers, easybell wants us to use P-Asserted-Identity to have these numbers displayed:

....
From: <sip:[email protected]>;tag=bfe91782-f8c5-4d6c-b809-3aec331f06e4

....
P-Asserted-Identity: "Hotline" <sip:[email protected]>

In my opinion “Hotline” has to be placed here : From: “Hotline” <sip:00496198…

You changed it here. As I said, the example does more than set the caller name.

The next line:

will just set the caller name, but its condition is not being matched.

Unfortunately, whoever wrote the example, assumed people would understand how it worked, and provided a more general example than needed.

Okay, now you confusing me.
Why are you supposing that

    -- Executing [s@macro-dialout-trunk-predial-hook:5] ExecIf("Local/01511zzzz@from-internal-00000012;2", "0?Set(CALLERID(name)="Hotline")") in new stack

this line does not match the condition?

Because the 0 before the ? is the result of evaluating the condition and 0 means false.

Note that, at this point, the previous line has already changed the caller ID number.

Do I understand correctly that you want the ‘hotline’ name and original caller’s number in the From header, and your pilot number in P-Asserted-Identity?

If so, I believe that sending the inbound leg through a Set CallerID application to rewrite the name, and using the predial hook to only set PAI should work.

If not, or you otherwise have trouble, turn on pjsip logger, call in through the problematic path, paste the Asterisk log for the call at pastebin.freepbx.org (including both received and sent INVITEs) and post the link here. If you are too new to post links, just post the last eight hex characters of the URL.

Their open user documentation is fragmented (normal run round in circles help pages) and only partially in English, but it looks like From user is the account name, which is the same as the pilot number in the form it would be dialled, from Germany as an international number (0049…).

It looks like DID is in the To header, and they seem fairly explicit that it is international format without the exit code (00), or a +.

Less clear is whether caller ID presentation numbers are in the same format.

It looks like they currently block a small number of misleading numbers, but otherwise trust that you to obey the rules and only use numbers you own (so forwarding a customer’s CLID would be a breach of their terms of service).

I couldn’t work out whether the partial INVITE is what he is currently sending, or what they ask for. I think it is important to know the former. In any case, the two numbers seem to be the same number, dialled in, form Germany, national an international formats, with exit codes.

On my reading, this is a breach of the terms of service, but not technically enforced.

In general, you may only display numbers that have been assigned to you or for which you are the subscriber.

Generell dürfen Sie nur solche Rufnummern anzeigen, die Ihnen zugeteilt wurden bzw. deren Zuteilungsnehmer Sie sind.

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