It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Private message API to give sticky notification

We are using a tool to send automated private messages through the REST API (/v2/user/{id_or_email}/message). It uses a regular account as the sender. Recipients receive messages fine, and a notification popup as expected.

If the recipient already has a conversation open with the sender, then the recipient will also get a sticky message counter on top of that conversation, indicating that there are unread messages. If the recipient does not already have a conversation open, there will be no such notification. In that case, unless the recipient notices the popup, he will not realize there was a message (until he gets the email notification about unread messages). This is unlike manual private messages, which will start a new conversation automatically if one doesn't exist already.

The same happens whether the sender is online or not. Most users use Windows desktop client, but the same behavior also appears on other devices.

What I want to achieve is to send private messages, and have recipients realize they have been messaged. Any clues to how I can achieve this?

5 answers

0 votes
AhmadDanial Atlassian Team May 27, 2018

Hey, Sigbjørn.

Can I please confirm with you if you have the notify flag set to true?

curl -H "Content-Type: application/json" -X POST -d "{\"message_format\": \"text\", \"notify\": \"true\", \"message\": \"Testing\" }" https://<fqdn>/v2/user/<user_id>/message?auth_token=<api_token>

I had this tested on Mac and Windows client and confirmed that I was still getting the pop up notification and the unread notification will be displayed on the left side of the client using the snippet example above. I'll also be interested to know how you use the API v2 on your end. If you can share an example, that will be great so I can test it on my end.

Yes, the notify flag is set to true. The code used is this:

public async Task PrivateMessageAsync(String user, String message, bool notify = false, MessageFormat messageFormat = MessageFormat.Html)
var endpoint = new System.Uri($"{user}/message");

dynamic jsonRequest = new JObject();
jsonRequest.notify = notify;
jsonRequest.message_format = messageFormat.ToString().ToLower();
jsonRequest.message = message;

using (var request = new WebClient())
request.Headers.Add("Authorization", "Bearer " + HipChatConnectionKey);
request.Headers.Add("Content-type", "application/json");
await request.UploadStringTaskAsync(endpoint, jsonRequest.ToString(Formatting.None));

screenshot.pngAttaching an image, on top what it looks like if the conversation with the sender is not already open, on the bottom what it looks like when it is open. You will notice that in the second case, the sticky message counters will be present.

AhmadDanial Atlassian Team May 29, 2018

Good day, Sigbjørn. 

I noticed that the parameter here is set to false:

bool notify = false

 Can you please confirm if the behavior is the same when you set it to true instead?

That is the default value of the parameter to the function. As you can see from screenshot #2, notifications do work (given that the conversation is already open), showing that the function is called with notify set to true. If I call the API with notify = false instead, then the message counter does not appear on top of the conversation. The function is called from this code:

await tools.PrivateMessageAsync(hipChatId, message, true);


Hello, Sigbjørn.


Thank you for the confirmation from your end. Since the notify is an essential parameter to indicate the users that there is a new message as mentioned in the send room notification API V2 page, I would recommend you to have it set to true rather than using the default value of false. As mentioned in the page:

Whether this message should trigger a user notification (change the tab color, play a sound, notify mobile phones, etc). Each recipient's notification preferences are taken into account.

Defaults to false.

Please let me know how it goes on your end. 

Does that answer your last question?

Anyone else who knows anything about this?

I have now changed the default value for the notify flag to true. As should be expected, this does not change the behavior, as the default value was not being used.

The behavior is still as follows: If the sender is not already visible in the list of people the recipient is talking to, then the sender will not appear in that list, and thus the sticky notifications will not be visible to the recipient. If the sender is already in that list, then sticky notifications will be visible as expected.

AhmadDanial Atlassian Team Jun 10, 2018

Hi, Sigbjørn. 

That is interesting. I figured that the function will work correctly since notify is set to true already:

public async Task PrivateMessageAsync(String user, String message, bool notify = true, MessageFormat messageFormat = MessageFormat.Html)

 Let us see if others might have another idea on this one.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Hipchat

Hipchat Cloud and Stride have reached End of Life (updated)

All good things come to an end - thanks to all our customers and partners who have been along the Hipchat and Stride journey with us.  As of Feb 15th 2019, Hipchat Cloud and Stride have reached ...

35,188 views 9 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you