How to get Slack private channel list using conversation API? - slack

I want to post on private channels in slack using slack conversation and chatPostMessage in java.
I tried getting slack private channels using conversations API but it is giving empty array in response
List<ConversationType> list = Arrays.asList(ConversationType.PRIVATE_CHANNEL);
ConversationsListResponse response1 = client.conversationsList(req -> req.token(slackToken).types(list));

Related

Retrieve Slack private channels without adding bot to them

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.

Getting Private Channel Info when Linking Public Slack Channel

I am trying to create a link to a public channel in a post message to slack programmatically.
Following the documentation, I am posting a slack message containing <#C...> with a valid public channel within my slack workspace. However, the display shows only Private channel info, instead of the actual channel.
Are there additional permissions or setup required?
Got it to work with using <#{normalized_channel_name}>

Slack Conversations API conversations.info "channel_not_found"

I have a Slack bot that uses a slash command, but I first need information from the conversation.
Required Scopes for conversations.info (mine only needs im:read and mpim:read):
channels:read groups:read im:read mpim:read
payload = request.form
headers = request.headers
trigger_id = payload['trigger_id']
channel_id = payload['channel_id']
user_id = payload['user_id']
timestamp = headers['X-Slack-Request-Timestamp']
conversation_info = slack_client.conversations_info(
token=SLACK_BOT_TOKEN,
channel=channel_id
)
This code is returning the "channel_not_found" error when I invoke the Slack Bot from within my personal DM's, am I missing something? I have both im:read and mpim:read scopes added. I even tried the tester from Slack's API page and it doesn't work either.
I have been ashed this on Slack Support, and they said, you can not see information about private channels and direct messages, which the bot is not member of. They said, privacy is over everything.
You can invite a bot into private groups with /invite #BotName, but you can't invite to direct messages.
You can only see information about direct conversation, if you are using a UserToken, and the token's owner is part of that DM.

Send context from bot - Microsoft bot framework

I am developing Bots using Microsoft Bot framework and I've a use-case where my bot have to send a custom context information to my application. I am thinking to use ChannelData like below.
Is this a correct placeholder?
Dictionary<string, string> context = new Dictionary<string, string>{
{ "foo","bar" }};
Dictionary<string, object> channelinfo = new Dictionary<string, object>
{{ "context", context }};
ResponseActivity.ChannelData = channelinfo;
You can add custom channel data to outgoing activities by creating a custom store middleware to modify activities sent by the user. Channel data is a channel-specific property bag that can be used to send non-standard in-band data.To implement channel-specific functionality, you can pass metadata to a channel in the activity object's channel data property. Take a look at the Backchannel Piggyback on Outgoing Activities Web Chat Sample in which all the 'DIRECT_LINE/POST_ACTIVITY' sent on the bot will have an email added to the channel data.
Depending on the channel you are using, you can make use of the channel data property to instruct your channel to implement the functionality. This documentation provides a detailed explanation on how to create a custom messsage for different channels.
A simple example of the channel data for a message via Facebook Messenger in NodeJS and C# is explained in detail in this blogpost.
Hope this helps.

Unable to get slack channel info when public channel changed to private

I created a public channel and changed it to private and invited my bot. Then with bot token I tried to access channel/group info using slack API https://api.slack.com/methods/groups.info but resposne is "channel_not_found" when I used https://api.slack.com/methods/groups.info
API I got "method_not_supported_for_channel_type"
Do you have any Idea how to get channel info when it changed from public to private.
Yes. The old style API methods (like channels.* and groups.*) do not work for those kind of channels.
You need to use the newer conversations.* methods like conversations.info instead.

Resources