From 16a4f37dac93ab0491173a6552f1157481d03297 Mon Sep 17 00:00:00 2001 From: Waleed Date: Fri, 14 Nov 2025 02:18:19 -0800 Subject: [PATCH] feat(slack): add better error messages, reminder to add bot to app (#1990) --- apps/sim/tools/slack/message_reader.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/sim/tools/slack/message_reader.ts b/apps/sim/tools/slack/message_reader.ts index eb92152f6e..ec14b2cf54 100644 --- a/apps/sim/tools/slack/message_reader.ts +++ b/apps/sim/tools/slack/message_reader.ts @@ -88,6 +88,23 @@ export const slackMessageReaderTool: ToolConfig< transformResponse: async (response: Response) => { const data = await response.json() + if (!data.ok) { + if (data.error === 'not_in_channel') { + throw new Error( + 'Bot is not in the channel. Please invite the Sim bot to your Slack channel by typing: /invite @Sim Studio' + ) + } + if (data.error === 'channel_not_found') { + throw new Error('Channel not found. Please check the channel ID and try again.') + } + if (data.error === 'missing_scope') { + throw new Error( + 'Missing required permissions. Please reconnect your Slack account with the necessary scopes (channels:history, groups:history).' + ) + } + throw new Error(data.error || 'Failed to fetch messages from Slack') + } + const messages = (data.messages || []).map((message: any) => ({ // Core properties type: message.type || 'message',