How to find all private channels using REST API?

Hi folks,

We have a requirement to send messages to group members from a custom-developed program using the Rocket.Chat REST API under a specified account.

Our specified account has the following roles:

  • admin
  • user
  • bot

For the admin role, all Permissions are checked except for:

  • Bypass rate limit for REST API
  • Bypass time limit
  • Impersonate Other Users

Initially, we tried using the REST API endpoint channels.list to find the private channel we wanted to send messages to, but we were unsuccessful.

Then we tried adding the specified account to the private channel and changing the endpoint to channels.list.joined, but we still couldnā€™t find the channel.

Finally, we were able to find the channel by changing the endpoint to rooms.get.

We would like to ask:

  1. In Rocket.Chat Version: 6.8.0 Community, even if the specified account has the View Private Room permission, is it still not possible to see all private channels?
  2. Is our approach to sending messages to private channels correct?

Thank you for taking the time to read this post.

IIRC you can only view rooms that you have joined.

Why not have a #notification channel where you post and only the selected members can see?

Or are these all individual messages?

It might be useful if you described what you are trying to achieve a little more.

We have an announcement channel, but since we define channels based on the responsible business units, if all members are in the same channel, we canā€™t distinguish which members should be notified about specific business-related messages. Additionally, in the business unit channels where members are responsible, they can interact and discuss the messages. However, if messages are sent in the announcement channel and are visible only to the specific member, it would not be convenient for discussions with other members. If the messages are broadcast to everyone, it might raise privacy issues as irrelevant individuals would see the information.

I donā€™t think you can send to an existing private chat - eg DM between two users - that you are not part of.

IIRC I think I have seen this answered before and the response is ā€˜Privacyā€™. I do understand why even an ā€˜adminā€™ isnā€™t permitted to jump into a chat between say the CEO and CFOā€¦

You would have to DM to the individual concerned.

I think Private channels are actually ā€˜groupsā€™ rather than ā€˜channelsā€™.

Check the rocketchat url eg this is the URL for a private group:

https://chat.myserver.com/group/it-stuff

Check this:

Thank you for reminding me of the difference between channels and groups.
After rethinking our needs, we actually need to be able to send notifications to members of channels or groups.
During testing, I found that regardless of whether the View Private Room permission is enabled or disabled,
channels.list can only search for public channels,
groups.listAll will always search for all public and private channels.
Although private groups can be searched, if the sender account is not a member of the group,
it will return an ā€œerror-not-allowedā€ error message and fail.
I also agree with the importance of privacy,
Allow members of private channels or groups to have the option to be notified,
and only join the sender account if necessary, This is actually what we need.

Likely that it is a permission for viewing via the browser, but not an API call. Have you tested this in a browser?

I am not sure that is going to be permitted for the reasons explained above.

Private means you cannot access the channel or DM unless you are allowed in somehow. I donā€™t think the developers are going to permit this, particularly not via the API.

You can try adding a feature-request (after having a good search through issues ) but I am not sure it will be considered.

You would probably have to run your own fork with modifications to permissions to be able to do what you require.

In the case of browsers,
whether the View Private Room permission is enabled or disabled,
it is only possible to search for public Channels or Teams.

Our current approach is that
when a user needs to receive notification messages,
we inform the user that they need to manually add the messaging account to
the corresponding channel or group and let the user to decide whether or not to do.

Ok.

I need to try & check/test a few things for you but I am away from today and back Wednesday.

Iā€™ll try & speak to a dev in the meantime to ask about this.

It may be an issue, or or may be a misunderstanding of how the setting works.

It might be worth a grep in the code to see.

Please be patient and I will get back to you soonest.

1 Like