Howto change ARI Registered Endpoints' CALLERID(name) when calling/originating

Asterisk used: 18.6.0
Asterisk API used: Primarily ARI, have tested this with AMI as well
Programming Language: NodeJS (with awry, and asterisk-manager)

Context: A control centre monitors vehicle via a third party software suite. If certain events occur in the third party software suite, this event is then forwarded to the application being developed (the application). The human operator is provided with a third party interface to “start-the-call”. The application then initiates all SIP communication between operator and vehicle. In certain situations, the vehicle provides a misscall to the application to trigger a certain event. The vehicle identifies if the CALLERID(name) is of a certain string. Based upon this string, the vehicle will enable and/or disable certain speakers and/or micrphones (think annunciation, covert alarm, normal call). This vehicle third-party app cannot be modified (:frowning:).
Vehicles and operators change frequently and the “valid” vehicles and operators are obtain via the third party.

Solution So Far: Vehicles and operators are registered via a Stasis application successfully. “Misscalls” and their associated events are handled correctly via ARI. Triggers from the operators are handled and initiating calls to the operators work. The extension.conf file is empty, the PJSIP file only has a network item in it.

The problem: I am currently unable to set the CALLERID(name) in any form or fashion with “dynamically” created Endpoints via ARI. In fact, when I do call the vehicle (either through call or originate) its origin/From field is always like below:

<--- Transmitting SIP request (1004 bytes) to UDP:192.168.88.26:5060 --->
INVITE sip:SIM9001@192.168.88.26:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.88.244:5060;rport;branch=z9hG4bKPjdaa83bcc-ef70-4bab-aa66-20bd1fc48a0c
From: <sip:SIM9001@192.168.88.244>;tag=a02837d4-9d9e-4603-9111-c81337f36aaf
To: <sip:SIM9001@192.168.88.26>
Contact: <sip:dispatcher-1@192.168.88.244:5060>
Call-ID: 28d9a5bb-53d4-434a-adda-794c8c079d4d
CSeq: 22845 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, path, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 18.6.0
Content-Type: application/sdp
Content-Length:   317

Notice also the “Contact:” portion above. I have no idea when I do a normal call (with pre-setup channels) and/or originate, it doesn’t say the something else and is instead using the Endpoint. If I change the dial command (pre-created channels) to:

tempCallResponse = await ariInstance.channels.dial({
    channelId: callEvent.endPoint[k].channelId,
    caller: callEvent.localChannelId
});

then the result is as follows (even though that local channel is the caller, why is the “From” itself):

INVITE sip:SIM9001@192.168.88.26:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.88.244:5060;rport;branch=z9hG4bKPjf6bece05-9ce2-47dd-a1a8-9217dddce87a
From: <sip:SIM9001@192.168.88.244>;tag=6d0390b9-6202-4b93-9b67-377468017e8f
To: <sip:SIM9001@192.168.88.26>
Contact: <sip:Local/TALK_STANDARD25775@192.168.88.244:5060>
Call-ID: 8e12f8ee-6214-4c87-bd26-2003b016adc6
CSeq: 6891 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, path, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 18.6.0
Content-Type: application/sdp
Content-Length:   315

As soon as I change the Asterisk config to not use dynamic Endpoints and use Extensions/Dialplans, it works to add a string to the “From:” so that it becomes:

From: "COVERT_CALL" <sip:Asterisk@192.168.88.244>;tag=a02837d4-9d9e-4603-9111-c81337f36aaf

Operators/Vehicles are registered as:

var dispatcherEndpointObject = {
   configClass : "res_pjsip",
   objectType : "endpoint",
   id : tempDispatcherName,
   fields : [
      { "attribute" : "from_user", "value": tempDispatcherName },
      { "attribute" : "disallow", "value" : "all"},
      { "attribute" : "allow", "value": "!all,speex,g722,ulaw,alaw" }, 
      { "attribute" : "rewrite_contact", "value": "yes" }, 
      { "attribute" : "context", "value": ariRegistrationExtensionContext }, //this is "default"
      { "attribute" : "transport", "value": ariRegistrationNetworkContext },
      { "attribute" : "callerid", "value": '"TALK_STANDARD" <'+tempDispatcherName+'>'}, //this I just added to test, but it doesn't work
      { "attribute" : "auth", "value": tempDispatcherName }, 
      { "attribute" : "aors", "value": tempDispatcherName }
   ]
}
var ariTempReturn = await ariInstance.asterisk.updateObject(dispatcherEndpointObject);

I tried pre-creating channels for the endpoints (not using Originate), and I tried to use ConfBridge application, but I am unable to set the “From” field at all …

A colleague indicated that it may be the ARI interface, however, after implementing the AMI interface, the CallerID fields are not honored at all (tried it even with Variable override):

var tempOriginateResponse = await amiInstance.action({
    'Action':'Originate',
    'ActionID':callEvent.callId,
    'Channel':'PJSIP/SIM9001',
    'Context':'stasis-LIOGateway',
    'Exten':'SIM9001',
    'Priority':1,
    'CallerID': 'TALK_STANDARD',
    'Variable': { 
        'CALLERID(name)':'TALK_STANDARD',
        'CALLERID(num)':'SIM9001'
    }
});

And the result:

<--- Transmitting SIP request (989 bytes) to UDP:192.168.88.26:5060 --->
INVITE sip:SIM9001@192.168.88.26:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.88.244:5060;rport;branch=z9hG4bKPj87992be8-2d75-4b39-b9e5-6c165c0cd11f
From: <sip:SIM9001@192.168.88.244>;tag=213ba3a9-38d5-43f7-bd73-601dde2c5e57
To: <sip:SIM9001@192.168.88.26>
Contact: <sip:192.168.88.244:5060>
Call-ID: 3d3dbf9e-d0d4-47cc-803c-c33c980d73ce
CSeq: 13595 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, path, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 18.6.0
Content-Type: application/sdp
Content-Length:   315

There is something I am not doing right with the “dynamic” endpoint registrations and/or their usage.
Can someone please point me in the right direction please?
The sad part is, that I could probably get it working by changing the pjsip.conf and extension.conf files when new data is recieved and force a reload … but I was hoping files are like in so 1993 …

I found a workaround, I do not think it is the most “elegant” workaround, or possibly event the correct one, but it looks like it is working without detrimental effects (so far). I set the PJSIP header for “From” directly via:

tempCallResponse = await ariInstance.channels.originate({
    endpoint: "PJSIP/"+callEvent.endPoint[k].displayName,
    context: ariRegistrationExtensionContext,
    extension: callEvent.workstationEndpoint,
    callerId: "<dispatcher-1>",
    variables:{
        'PJSIP_HEADER(add,From)':'"TALK_STANDARD" <sip:dispatcher-1@192.168.88.244>'
    }
});     

I thought I just had to “update” the header item, but according to Asterisk, there was no such item at this stage when the parameter is supplied.

However, the result, looks a bit “wonky”, but still works for my specific situation (notice the double “From:” at the bottom):

<--- Transmitting SIP request (1061 bytes) to UDP:192.168.88.26:5060 --->
INVITE sip:SIM9001@192.168.88.26:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.88.244:5060;rport;branch=z9hG4bKPjb21f77a0-4128-48b5-a95f-99fbe073a25d
From: <sip:SIM9001@192.168.88.244>;tag=5ea222ca-921b-4c72-b294-42276b31902f
To: <sip:SIM9001@192.168.88.26>
Contact: <sip:dispatcher-1@192.168.88.244:5060>
Call-ID: 0b1690c2-1dfd-427f-94d1-57c794fc9aa2
CSeq: 10317 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, path, histinfo
Session-Expires: 1800
Min-SE: 90
From: "TALK_STANDARD" <sip:dispatcher-1@192.168.88.244>
Max-Forwards: 70
User-Agent: Asterisk PBX 18.6.0
Content-Type: application/sdp
Content-Length:   317

I am still uncertain as to why ARI’s “dynamic” registration makes the To and From when calling/originating the same CALLERID(name) the same even when they are supposed to be different. I hope someone with more experience and knowledge can assist me there.

Best regards,

Dawie

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