From 5487d4c615ebd5da0e38dbb72d7cd812834cffd3 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Wed, 18 Jun 2025 05:14:56 +0530 Subject: [PATCH] fix: Include private channels in Slack integration pagination (#11751) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://linear.app/chatwoot/issue/CW-4507/slack-integration-not-showing-private-channels ## Problem When the Slack workspace has many channels (requiring multiple API requests to fetch all of them), our system was only looking for private channels in the first batch of results. All subsequent batches were missing the instruction to include private channels, so they only returned public channels. ## Root Cause - Initial API call correctly specified `types: 'public_channel,private_channel'` - Pagination loop only passed `cursor` parameter, omitting `types` and `exclude_archived` - Subsequent pages defaulted to public channels only ## Changes - Fixed parameter formatting in `types` (removed space: `'public_channel, private_channel'` → `'public_channel,private_channel'`) - Added missing `types` and `exclude_archived` parameters to paginated `conversations_list` calls --------- Co-authored-by: Sojan Jose --- lib/integrations/slack/channel_builder.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/integrations/slack/channel_builder.rb b/lib/integrations/slack/channel_builder.rb index 1edacf8f7..707254e1f 100644 --- a/lib/integrations/slack/channel_builder.rb +++ b/lib/integrations/slack/channel_builder.rb @@ -24,10 +24,14 @@ class Integrations::Slack::ChannelBuilder end def channels - conversations_list = slack_client.conversations_list(types: 'public_channel, private_channel', exclude_archived: true) + conversations_list = slack_client.conversations_list(types: 'public_channel,private_channel', exclude_archived: true) channel_list = conversations_list.channels while conversations_list.response_metadata.next_cursor.present? - conversations_list = slack_client.conversations_list(cursor: conversations_list.response_metadata.next_cursor) + conversations_list = slack_client.conversations_list( + cursor: conversations_list.response_metadata.next_cursor, + types: 'public_channel,private_channel', + exclude_archived: true + ) channel_list.concat(conversations_list.channels) end channel_list