bolt-python icon indicating copy to clipboard operation
bolt-python copied to clipboard

Get Channel_id through channel_name besides using conversations.list

Open Tang20031010 opened this issue 1 year ago • 4 comments

(Describe your issue and goal here)

Reproducible in:

The slack_bolt version

slack-bolt==1.18.1 slack_sdk==3.27.2

Python runtime version

Python 3.12.3

OS info

ProductName: macOS ProductVersion: 14.4.1

Steps to reproduce:

I am trying to get channel id by channel name. I would like to let the user input a channel's name and use that to get the channel's id since I need the channel id to do conversations.join. I have found one thread in https://github.com/slackapi/bolt-js/issues/1725 and tried the suggestion by using conversations.list to filter and then use the conversations.info. However, there are too many channels in the organization. I have tried pagination but still failed to retrieve all channels through conversations.list. I think there are more than 50000 channels and the return from conversations.list is not stable. Since that post is in 2023, I am wondering if we have additional solutions to this situation. The worst case I am thinking is letting user input the channel id.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Tang20031010 avatar Jun 13 '24 17:06 Tang20031010

I would like to let the user input a channel's name and use that to get the channel's id since I need the channel id to do conversations.join.

Could you use the Block Kit Conversation Select Menu? It will render a drop down menu of conversations (channels, public or private, even DMs and MPDMs) that is contextual to the user (meaning: the user has access to them). Then, you can listen to block_actions payloads on this element to get channel / conversation ID.

filmaj avatar Jun 13 '24 17:06 filmaj

Thank you for your quick response! I looked into it; however, this does not seem quite fit to my situation as what I want is to let the user only interact with the UI I implemented instead of going to slack to do the operation.

Tang20031010 avatar Jun 13 '24 18:06 Tang20031010

I see. Yes, it's a common request and unfortunately we have no good answer. If you have access to an admin token, you could use the admin.conversations.search API as it accepts a query parameter for the channel name. The other is to paginate through conversations.list, as you pointed out.

filmaj avatar Jun 13 '24 18:06 filmaj

Thank you! I probably need to go with letting the user input channel_id.

Tang20031010 avatar Jun 13 '24 19:06 Tang20031010

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] avatar Jul 15 '24 00:07 github-actions[bot]

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

github-actions[bot] avatar Jul 29 '24 00:07 github-actions[bot]