CustomPresence state is not included in NOTIFY packets

Hello All,

I’m trying to set up the custom presence feature with PJSIP using the simple configuration below.

[default]
exten => _6XXX,1,Set(PRESENCE_STATE(CustomPresence:${EXTEN})=away,temporary,test)
same => n,NoOp(${PRESENCE_STATE(CustomPresence:${EXTEN},value)})
same => n, Dial(PJSIP/${EXTEN})
same => n,Hangup()

[subscribe]
exten => 6001,hint,PJSIP/6001,CustomPresence:6001
exten => 6002,hint,PJSIP/6002,CustomPresence:6002
exten => 6003,hint,PJSIP/6003,CustomPresence:6003
subscribe_context = 'subscribe'

My device state subscriptions work just fine; device state updates sent through NOTIFY packets and subscribers are able to see the xml with the relevant information.

I can also query my custom presence states through CLI using the commands below:

*CLI> presencestate change CustomPresence:6003 "Dnd,upstairs,eating lunch"
Changing 6003 to Dnd

*CLI> core show hints
6003@default        : PJSIP/6003,CustomPre  State:Idle            Presence:dnd             Watchers  1

However the subscribers are not able to see any information regarding Custom Presence States on NOTIFY packets. The XML sent along with the NOTIFY packet has only device state info.

-- Executing [6003@default:1] Set("PJSIP/6002-00000000", "PRESENCE_STATE(CustomPresence:6003)=away,temporary,test") in new stack
<--- Transmitting SIP request (1140 bytes) to UDP:10.0.0.13:5060 --->
NOTIFY sip:2b3cjr7c@192.0.2.217;transport=wss;alias=10.0.0.42~35170~6;alias=10.0.0.42~35170~6 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.13:5080;rport;branch=z9hG4bKPj4e7b580d-848e-48d4-b75e-febf4350864a
From: <sip:6003@10.0.0.13>;tag=8b7d3417-5311-437f-86ba-d56a69a8beb0
To: "6002" <sip:6002@10.0.0.13>;tag=96fjorlk6m
Contact: <sip:10.0.0.13:5080>
Call-ID: tvbg2rpsr8ghq99fo1u4
CSeq: 2351 NOTIFY
Route: <sip:10.0.0.13;lr;r2=on;ftag=96fjorlk6m;nat=yes>
Route: <sip:10.0.0.13:8060;transport=ws;lr;r2=on;ftag=96fjorlk6m;nat=yes>
Event: presence
Subscription-State: active;expires=265
Allow-Events: message-summary, presence, dialog, refer
Max-Forwards: 70
User-Agent: Asterisk PBX 18.4.0
Content-Type: application/pidf+xml
Content-Length:   390

<?xml version="1.0" encoding="UTF-8"?>
<presence entity="sip:6003@10.0.0.13:5080" xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid">
 <note>Ready</note>
 <tuple id="6003">
  <status>
   <basic>open</basic>
  </status>
  <contact priority="1">sip:6002@10.0.0.13</contact>
 </tuple>
 <dm:person />
</presence>
.
.
.

*CLI> core show hints
6003@subscribe      : PJSIP/6003,CustomPre  State:Idle            Presence:away            Watchers  1


Also it may be worth mentioning that I’m not using Digium phones and I haven’t installed the DPMA.
I use a WebRTC browser phone.

According to the this Wiki page I should be OK to use this feature without a Digium phone as long as I can make use of the XML sent.

“When a SIP device is subscribed to a hint you have configured in Asterisk and that hint references a presence state provider, then upon change of that state Asterisk will generate a notification. That notification will take the form of a SIP NOTIFY including XML content. In the expanding panel below I’ve included an example of a presence notification sent to a Digium phone. This particular presence notification happened when we changed presence state for CustomPresence:6002 via the CLI command ‘presencestate change’.
.
.
The CustomPresence provider itself is device-agnostic and support for other devices could be added in. Or devices themselves (soft-phone or hardphone) could be modified to interpret the XML send out in the Presence State notification.”

As you can see above I am able to change/read custom presence states through Dialplan and CLI however I’m not able to send that information to subscribers.

I got creative and tried a combination of different configurations but was not able to change the result. Any help would be greatly appreciated.

Thanks,
Kaan.

The given presence information is only sent to Digium/Sangoma devices[1] on PJSIP.

[1] asterisk/res_pjsip_pidf_digium_body_supplement.c at master · asterisk/asterisk · GitHub

1 Like

Thank you for your swift response, I really appreciate it. It’s heart breaking that we can’t use this nice feature. It would help me quite lot. I should probably create another topic for this but if you don’t mind I will ask another question here; I’m working on a peculiar scenario where I’m trying to send the callerid of the caller to all my presence subscribers so that I can have a presence state such as “On the call with xxx”. Is there any other way I could achieve this? Could you please show me a direction?

The dialog-info+xml code provides information on who is at least calling, I don’t recall if it extends to being on call. There’s no other support for doing such a thing in NOTIFY requests without adding custom code.

1 Like

Thanks a lot, I will take a look at that.