Is conversation Id in slack immutable? - slack

I need to send messages to channels. Documentation give advice to receive all channels, pick you channel by name and after all send message by conversationId.
I want to cache the value of conversation id. But I want to be sure it won't be changed.

Documentation says
Recently we began preserving the channel ID of channels converted from
public to private.
So we can conclude, that it is immutable now
https://api.slack.com/changelog/2018-09-more-reasons-to-be-a-conversations-api-convert

Related

Get message event_id from reaction_added in slack api

Using the slack_sdk in python, I am attempting to store who reacts to a message sent by the bot, and what what specific message they reacted to. The payload I get from a reaction_added lets me know who sent the message someone reacted to, but not the specific message event_id. Is there some way where I can tell what message someone reacted to?
the Payload received does not seem to carry the data I need. I checked the api docs, but couldn't find how to get more information on the event_id of a message someone reacted to.
The Event IDs for each event are only so useful for correlating activities between events. You won't really find a way to link the actual event describing "what happened" with another event.
However, you can correlate what the events reference together. In reaction_added you receive a bundle of data in item describing what the item_user reacted to. When it's a message, type will be set to message, channel will indicate the ID of the channel where the message belongs and the ts value will point to a specific message ID in that channel.
If you previously received (& persisted) the message that has been reacted to, you'll need to correlate that with the ts and channel values you'll also find in each message.
If you don't have that message and need more data about it and have the appropriate permission scopes, you can use the Web API method conversations.history to fetch a single message as documented here.

Slack `member_joined_channel` - how to check if my bot was invited?

I want to send a message to any public channel that my bot gets added to. I notice there's the member_joined_channel event as documentated here, however I'm not sure how to figure out when to determine if my bot was the invited member. I know there's the user property, but I don't want to hardcode my bot's user ID.
I'm not familiar with the slack API, but i found this endpoint :
https://api.slack.com/types/conversation
In the response, you have a flag is_member which contains what you need I think :
is_member indicates whether the user, bot user or Slack app associated
with the token making the API call is itself a member of the
conversation.
EDIT:
then, you can retreive the list of public channel and have this flag on every channel accessible :
https://api.slack.com/methods/conversations.list
If you are writing a WebSocket-based "RTM" bot, you can listen for the channel_joined event, which is sent only for your own user/bot.
For the more typical Webhook-based bot, the best choice is to listen for the member_joined_channel event and compare the user field if you want an event-based implementation. Hardcoding or otherwise storing your bot's user id is a necessity.
Otherwise, as suggested in the previous answer, you can periodically query all conversations with the conversations.list method and check if you have become a member using the is_member field.
In case one of these methods does not provide the is_private field that you need to determine whether a channel is public, you can use the conversations.info method, which returns a channel object with the is_private field.
Coversation info is your friend https://api.slack.com/methods/conversations.info

Slack API: How to send a scheduled private message to every member in the channel?

I want to send a weekly private message to all channel members.
I'm using currently using app.event('app_home_opened') to do such a thing. But I want the open rate to be higher, and that's why I want the bot to send the message automatically.
chat.scheduleMessage works perfectly but I have to pass a channel id as a parameter, meaning that only 1 person will receive the message.
How can I achieve what chat.scheduleMessage does, but for every single member?
According to my search and knowledge I think with slackapi we can send message only one channel at a time..
But I think if you implement like this then you can send messages to multiple channel
Steps:
add all channel in one array and apply loop , then one by one channel id will pass and message will send to all channel. If you want to different channel messages to all channel then you can also add messages in channel array
Hope you got solution

Can you programmatically determine the sender of a value down a go channel from the receiver?

Lets say I have a buffered channel, with different functions {A,B,C and D} sending values into the channel at different times. Now if I read a notification from the channel is there any way to determine which sender it came from? Logically I would assume no but I don't have enough understanding of channel internals to know what is possible yet?
If this channel was perhaps a unbuffered channel could you find the corresponding sender as if you are receiving a value you cant move on until there is one sender sending at that exact time.
Is the only way to be sure to load up delve and take a look at all the goroutines that are operating at the time or put logging statements before every send to the channel?
Thanks
It's not possible to tell who sent the value you receive from a channel.
But it's easy to implement that if you need it. Just wrap the value and a sender ID in a struct, and modify senders to send a struct value on the channel, filled the sender ID.

Slack API - Number of messages sent by a user

i am trying to use the API to get the total number of messages posted by each user during a certain period. Ideally, I would be able to break the number of messages by the type of channel (public, private, direct messages.) Is this possible? I am looking through the API documentation but haven't found anything. I would be using it to create a script that would automatically generate weekly activity reports.
Thank you for any advice you can provide!
There is no special endpoint for this information as far as I know, but you can generate something similar yourself by looping though all channels and counting the message per user, e.g.
Get list of all channels with conversations.list
Get history of each channel with conversations.history
Count messages per user
Of course your results would not include message from channels, that your bot has no access too (e.g. some private channels, direct message channels).

Resources