diff --git a/llama-index-integrations/readers/llama-index-readers-slack/llama_index/readers/slack/base.py b/llama-index-integrations/readers/llama-index-readers-slack/llama_index/readers/slack/base.py index 7bd71596438e9..1d31d6c30a892 100644 --- a/llama-index-integrations/readers/llama-index-readers-slack/llama_index/readers/slack/base.py +++ b/llama-index-integrations/readers/llama-index-readers-slack/llama_index/readers/slack/base.py @@ -243,14 +243,12 @@ def _is_regex(self, pattern: str) -> bool: except re.error: return False - def _list_channels(self) -> List[Dict[str, Any]]: - """List all channels (public and private).""" + def _list_channels(self, types: str) -> List[Dict[str, Any]]: + """List channels based on the types.""" from slack_sdk.errors import SlackApiError try: - result = self._client.conversations_list( - types="public_channel,private_channel" - ) + result = self._client.conversations_list(types=types) return result["channels"] except SlackApiError as e: logger.error(f"Error fetching channels: {e.response['error']}") @@ -275,7 +273,9 @@ def _filter_channels( filtered_channels.append(channel) return filtered_channels - def get_channel_ids(self, channel_patterns: List[str]) -> List[str]: + def get_channel_ids( + self, channel_patterns: List[str], types: str = "public_channel,private_channel" + ) -> List[str]: """Get list of channel IDs based on names and regex patterns. Args: @@ -287,7 +287,7 @@ def get_channel_ids(self, channel_patterns: List[str]) -> List[str]: if not channel_patterns: raise ValueError("No channel patterns provided.") - channels = self._list_channels() + channels = self._list_channels(types) logger.info(f"Total channels fetched: {len(channels)}") if not channels: