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?
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does that answer your last question?
Anyone else who knows anything about this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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($"https://api.hipchat.com/v2/user/{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));
}
}
Attaching 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.