Retrieve Slack private channels without adding bot to them - slack

I want to retrieve all channels in my workspace using Slack API but my private channels are not listed unless I add my bot to them using Slack desktop/mobile app
Is this even possible to accomplish? Since the scope for reading private channels states:
View basic information about private channels that your slack app has been added to
which implies I should add my bot to the channel before reading it.

Bot users behave similarly to regular Slack users in that they only have visibility into conversations they are members of. Unfortunately, there is no way to gather private channel data without the bot being in the channel.

Related

Slack channel not found. Private slack channel from a docker container

I have set up a slack app to allow me to send notifications from my code to a private slack channel.
I have invited the bot to the channel, and when I run the app from the command line, all is good.
However, when I try and run it from a docker container, I get channel not found. If I try and use exactly the same code, and send a message to a bot in a public channel, no issues all is good.
Both bots have permissions, chat:write and chat:write.public
Why would this only be working on some machines and not others?
I know this probably doesn't have enough detail, but I'm not sure what is needed to help diagnose this.
More information:
Thanks to #Suyash Gaur I didn't know about the groups scope. I've now added groups:write and groups:history to the app, but am still getting the same error from the docker version of the app.
The membership of the channel I'm trying to write too shows
cwpr_notifications on Aug 3, 2021
Can post messages to specific channels in slack, send messages as #cwprnotifications, send messages to channels #cwprnotifications isn't a member of, manage private channels that cwpr_notifications has been added to and create new ones, and view messages and other content in private channels that cwpr_notifications has been added to.
I am using a bottoken and channel ID to send the message. Do I need something else for a private channel.
When I first used the bot from the command line run, I had to invite the app to the channel to get it to work, but surely I only need to do that once?
I've confirmed that the environment variables are getting passed in correctly.
With limited set of information provided, I can only say that:
If the public channel is accessible and private channel is not,
It seems like an issue of scopes.
For public channels, scopes start with channels:*
For private channels, scopes start with groups:*
Can you look into the app's configuration and confirm the permissions are configured correctly?

Slack Events API - Only able to subscribe to messages posted in public channels?

I just finished integrating a Slack app into my Slack workspace, and now I'm trying to simply subscribe to events so that I can respond to certain types of messages. However, I noticed that the POST request from the Slack Event Subscription process is only occurring when a message in a public channel is being posted, not private channels.
The bot user is in both the public and the private channel, so I'm not quite sure why this is happening. The only thing that I can see in the documentation (https://api.slack.com/apis/connections/events-api) is this:
Permission model
The Events API leverages Slack's existing object-driven OAuth scope
system to control access to events. For example, if your app has
access to files through the files:read scope, you can choose to
subscribe to any or none of the file-related events like file_created
and file_deleted.
You will only receive events that users who've authorized your app can
"see" on their workspace (that is, if a user authorizes access to
private channel history, you'll only see the activity in private
channels they are a member of, not all private channels across the
workspace).
Bot users may also subscribe to events on their own behalf. The bot
scope requested when workspaces install your bot covers events access
for both the Events API and the Real Time Messaging API.
but this still doesn't clarify why it's not subscribing to private channels, only public channels.
Assuming you are subscribed to 'Message' event.
To receive 'message' event from different conversation types, you need different scopes.
https://api.slack.com/events/message
Required scopes : channels:history, groups:history, im:history, mpim:history
Scope required for Private channel is groups:history

How to restrict user adding people into slack channel using Slack API?

I want to restrict users to add another user into channel. All I want is if I am adding a new user into a channel a notification triggers to the admin and once admin approves it then only that user can be added. Is this possible in Slack using Slack API. If yes, then what can be the workflow for this?
I got the answer. Following APIs can be used to achieve the same
channels.kick for Public channels
groups.kick for private channels

How to see that someone made public channel private in Slack?

I have no idea how to do it using EventsAPI from Slack.
So, our bot does this:
Creates public channel #test
Invites the bot to the channel using user token
From now on, we are using bot token to post messages on the channel
The problem happens when someone converts public channel to private. The ID of the channel changes and the bot gets error channel_not_found.
Do you have an idea how to track this change and update ID on our system automatically? Bot is still the member of the channel!
I found a way and it was also confirmed by Slack Help team.
Basically when channel is converted to private, you get these events:
channel_deleted with id of your public channel
member_joined_channel with id of new private channel and bot_id
When you get member_joined_channel, retrieve from Slack the name of new channel and if it matches your previous public channel then you know it is the same one but private now.
Slack does not allow to create channels with the same name so this is the indicator.
I just tested it with production app and it works! :)
I don't think that is currently possible.
Naturally, you would expect a specific Slack event for that case to fire, when a channel is converted, but there does not appear to be one. If you need this I would suggest to write a request they add an event for it.
One thing you can do is restricted who can create private channels in your Slack workplace to limit the risk of unintended use.
However, you can prevent this error from occurring by checking which public and private channels exist with conversations.list, and which channels you bot is a member with conversations.member.

Can user resume a conversation in a different channel? (Bot Framework)

Let's think of the following example:
1) I have a certain bot deployed on Azure
2) Bot can be talked via Facebook Messenger and via Skype
3) A certain user talks to the bot via Facebook Messenger and then he leaves.
4)A couple of minutes ago the same user resumes the conversation with the bot, but via Skype.
Is this possible? I assume Bot Framework doesn't have anything included for this, hence, that this isn't posible (as conversations are independent and state changes depending on the channel). Is there any way to identify a user (via some authentication method maybe), and then making this logic again?
Do any of you know any workaround for this?
Thanks in advance!
The Bot Framework Connector service is a component which provides a single API for your bot to communicate across multiple client services such as Skype, Email, Slack. Every bot and user has an account within each channel.
The channel account contains an identifier (id) and other informative bot non-structural data, like an optional name.
And there us unique conversation ID created for each conversation of each user for each channel. And you can customize your channel capabilities as described here.
Regards,
Jyo

Resources