Cannot remove a user from ms teams public channel - microsoft-teams

We have a teams account which has different channels like Marketing, Sales etc. But every member on teams is part of all public channels there is no option to remove members from public channel. Is this is the default behaviour of teams I mean we can't remove a member from public channel?

Yes that's correct, and the terminology makes sense in that regard - you're adding the person to the "Team", and that means all public content for that Team (channels, docs, etc.). If this is a problem, you'd need to use private channels, or separate Teams, or similar. Recall though that users can show/hide channels in the left menu, and you can "tag" users to target communications at them, as some examples of ways to help.

Related

How to add a Member to Channel with Discordgo

I want to implement a "Ticket" funktion in my discordgo Bot.
The channels for the tickets are created in a category that is only visible for team members. So, i want to add the User to the Channel but i dont find a solution for this.
My question is now: is there even a way to make this, or can i give up on this

How to automatically add group members to slack channel that fits a certain REGEX

Whenever there is a channel with the name that matches a certain regex, we want to add a certain group of members to these channel automatically. For example, if a new slack channel with the name that matches the regex INC-.* is created, slack group #incidentmembers will be added to that new slack channel automatically
Is there a way to configure this in Slack?
There's no native way to do this in Slack, but you could build something using the public APIs. Specifically you would
Listen to the channel_created event which fires when a public channel is created, which you can then regex as you see fit.
Grab the membership of the relevant User Group using usergroups.users.list (if the membership is static you could probably skip this)
Use conversations.invite to add the users to the channel
One limitation of this approach is that you won't get channel_created events for private channels. There's no way around this I'm afraid.

Microsoft Graph API get channel members

I am trying to get a list of members in Microsoft teams graph API. I did not find anything in the official documents. I am able to get list of teams and channel but I need to get the list of members to belong to the specific channel. Can anyone have an idea how can I get that?
Public channels don't have "members". The Team (basically group) has members. So you can find the list of members of a channel by listing the group members.
To support Private channels you need to use the beta API.
There is no documented API to list the private channel members, but reading between the lines of the Private Channel Add Member API, my guess that if you do a:
GET https://graph.microsoft.com/beta/teams/<group_id>/channels/<channel_id>/members
you will get a list of private members. In fact it's documented here at the bottom of the page.

API method for listing joined channels of user / bot

Does Slack provide a method that allows me to retrieve a list of all joined channels of a user or bot?
I am unable to find a proper API method and want to avoid using either the default channel.list or group.list since it would be expensive to execute 2 api calls and crawl through all channels and match the members ids, possibly even use pagination because of the member array limits of each channel.
There is no single API method that gives you all joined channels of a user / bot with a single API call.
The quickest methods (with two API calls) is indeed calling channels.list and groups.list and matching the result against your user ID, however this is not the recommend approach due to the recently introduced member cap to max. 500 members per channel. Note that this is a hard cap (!!), so you can't get additional members by pagination.
The recommended approach is to use the newer conversations methods, which have the benefit to work for both public and private channels and will return the complete list of members (with pagination).
However, this approach will require even more API calls:
Get list of all public and private channels with conversations.list
Get members per channel with conversations.members per channel
Compile list of channels per user by comparing user ID with all
members of all channels.
If you feel that this function is missing in the API I would recommend sending a feature request to the Slack team.

Get list of channels a user is a member of

Writing a slack bot and I would like to be able to get a list of all the channels my bot is a member of. One way to do this is to call https://slack.com/api/channels.list, get a (potentially large) list of all channels and then search for the channels that the current (bot) user is a member of. This works fine, but seems very heavy handed.
Is there a better way? To get just the channels that a given user is a member of?
I think users.conversations is what you're looking for. Without additional params it will return all public channels the calling user is a member of.
No, there is no shorter way to get this information.
Actually, Slack recommends to use the new conversations methods for this task, since the members property in all other methods, e.g. channels.list has recently been changed to only return a truncated user list. See here for details.
With conversations you have to make an additional call per channel to get all channels a user is a member of. However it will work with all types of channels (e.g. public channels, private channels) at the same time.
The basic approach is:
Get the list of all conversations from conversations.list
Get the list of members per conversation form conversations.members.
So if you want your Slack app to be future proof and also work with large number of users better use the conversations methods for your task.
FYI you can now list user channels/conversations using:
https://api.slack.com/methods/users.conversations

Resources