I have added a slack conversation dropdown and in the response I want to save/show channel name (or conversation name). I'm able to get the public channels information through conversation.info API but for the private channels, I am not able to fetch any details. Can someone help me how I can get the names along with channel id (or conversation id).
This is the response from the slack on selecting a channel
{'values': {'channel_block': {'selected_action_id': {'type': 'conversations_select', 'selected_conversation': 'G0*****JM'}}}}
The token you're using to call conversations.info must have access to the channel in question before you can access it. I'm assuming it doesn't, but without seeing the response from the API I can't be sure.
Related
I would like to send messages to users through Slackbot, just like integration apps such as Zapier.
If I set the channel ID to the user ID it sends a 1:1 message showing up in the Apps tab, but what I really would like to do is to send a message in Slackbot, as I want to create a seamless experience for a Workflow I'm creating.
Then, if I try adding the Slackbot channel ID it returns channel_not_found and there's no way to add the App there.
My current bot token scope to send messages is: chat:write and I'm sending a message using chat.postMessage
Do I need a different scope? Different API method? I've tried going through some other questions/answers, but they look outdated
I'm building a messaging integration with Slack and a client. I need to show the badges on the corresponding conversations when the users logs in to the client to show the client how many unread messages it has.
I know that the channels.history method had the unreads parameter which would return as part of the response the amount of unread messages according to the user token, but that method is deprecated and my app is too new to use it.
I'm using the conversations.history now to retrieve the messages which is what slack suggest to use instead of the deprecated method channel.history, but this new method doesn't have that parameter and doesn't show any info regarding the amount of unread messages in the conversation.
As my app is a new one and not a classic one, I cannot use the RTM API.
I'm also subscribed to the message events so that I know when a new message was posted.
My issue is that I need to know how many new messages were sent to the user while he was not logged in.
Is there any way to get that info?
Unread count is in conversations.info method, not in conversations.history. There in unread_count and unread_count_display property in reponse. Documentation is here.
I have tried to send MS Teams bot message request via rest api:
End point: https://smba.trafficmanager.net/ca/apis/v3/conversations/{conversation id}/activities
{"text":"test","type":"message"}
And got empty response:
{}
The message i sent did not appear in the conversation.
Any idea where i could have misconfigured?
It is possible that trustServiceUrl needs to be run before a message is sent, i can't find equivalent rest api to call.
You definitely do need call trustServiceUrl before sending the message. In addition, you need to have additional properties on your activity, like the destination user or tenant id. Please refer to the documents on this, and good starting places are here and here.
I'm working on a new Workspace app for Slack. I have a use case where I need to send notifications to users in Slack, through a direct message (or IM). Since the chat.postMessage endpoint requires a channel ID, I can get the existing IM channels using conversations.list and send them the notification.
However, if the user hasn't yet opened an IM channel from their side, I need to create one. It seems that neither Web API endpoints (conversations.open or im.open) support Workspace tokens. I keep getting not_allowed_token_type error response. I can create a public channel with conversations.create, but that's not what I need.
Is there another to open an IM channel to a user when using a Workspace token?
Took me awhile to figure this out. You need to add/request the conversations.app_home:create scope to your permissions. Then you can just specify the user ID as the channel arg in a chat.postMessage call.
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.