diff --git a/apps/docs/content/docs/de/tools/slack.mdx b/apps/docs/content/docs/de/tools/slack.mdx index 5f788a152c..4d7671b465 100644 --- a/apps/docs/content/docs/de/tools/slack.mdx +++ b/apps/docs/content/docs/de/tools/slack.mdx @@ -110,7 +110,7 @@ Lesen Sie die neuesten Nachrichten aus Slack-Kanälen. Rufen Sie den Konversatio | `authMethod` | string | Nein | Authentifizierungsmethode: oauth oder bot_token | | `botToken` | string | Nein | Bot-Token für benutzerdefinierten Bot | | `channel` | string | Ja | Slack-Kanal, aus dem Nachrichten gelesen werden sollen (z.B. #general) | -| `limit` | number | Nein | Anzahl der abzurufenden Nachrichten (Standard: 10, max: 100) | +| `limit` | number | Nein | Anzahl der abzurufenden Nachrichten (Standard: 10; Slack begrenzt Nicht-Marketplace-Apps auf 15 pro Anfrage) | | `oldest` | string | Nein | Beginn des Zeitraums (Zeitstempel) | | `latest` | string | Nein | Ende des Zeitraums (Zeitstempel) | @@ -120,6 +120,32 @@ Lesen Sie die neuesten Nachrichten aus Slack-Kanälen. Rufen Sie den Konversatio | --------- | ---- | ----------- | | `messages` | array | Array von Nachrichtenobjekten aus dem Kanal | +### `slack_thread_reader` + +Lesen Sie die Stammnachricht und alle Antworten aus einem bestimmten Slack-Thread. + +#### Eingabe + +| Parameter | Typ | Erforderlich | Beschreibung | +| --------- | ---- | -------- | ----------- | +| `authMethod` | string | Nein | Authentifizierungsmethode: oauth oder bot_token | +| `botToken` | string | Nein | Bot-Token für benutzerdefinierten Bot | +| `channel` | string | Ja | Slack-Kanal, der den Thread enthält | +| `thread_ts` | string | Ja | Zeitstempel der Stammnachricht, die gelesen werden soll | +| `limit` | number | Nein | Anzahl der Thread-Nachrichten (Standard: 15; Slack begrenzt Nicht-Marketplace-Apps auf 15 pro Anfrage) | +| `cursor` | string | Nein | Paginierungs-Cursor zum Abrufen weiterer Antworten | +| `oldest` | string | Nein | Beginn des Zeitraums (Zeitstempel) | +| `latest` | string | Nein | Ende des Zeitraums (Zeitstempel) | + +#### Ausgabe + +| Parameter | Typ | Beschreibung | +| --------- | ---- | ----------- | +| `thread_ts` | string | Zeitstempel der Stammnachricht des Threads | +| `messages` | array | Array der Thread-Nachrichten (Stamm + Antworten) | +| `has_more` | boolean | Zeigt an, ob weitere Antworten abgerufen werden können | +| `next_cursor` | string | Cursor zum Abrufen der nächsten Seite von Antworten | + ### `slack_download` Eine Datei von Slack herunterladen diff --git a/apps/docs/content/docs/en/tools/slack.mdx b/apps/docs/content/docs/en/tools/slack.mdx index 3054a9a4b3..7267f1d665 100644 --- a/apps/docs/content/docs/en/tools/slack.mdx +++ b/apps/docs/content/docs/en/tools/slack.mdx @@ -112,7 +112,7 @@ Read the latest messages from Slack channels. Retrieve conversation history with | `authMethod` | string | No | Authentication method: oauth or bot_token | | `botToken` | string | No | Bot token for Custom Bot | | `channel` | string | Yes | Slack channel to read messages from \(e.g., #general\) | -| `limit` | number | No | Number of messages to retrieve \(default: 10, max: 100\) | +| `limit` | number | No | Number of messages to retrieve \(default: 10, Slack limits non-Marketplace apps to max 15 per request\) | | `oldest` | string | No | Start of time range \(timestamp\) | | `latest` | string | No | End of time range \(timestamp\) | @@ -122,6 +122,32 @@ Read the latest messages from Slack channels. Retrieve conversation history with | --------- | ---- | ----------- | | `messages` | array | Array of message objects from the channel | +### `slack_thread_reader` + +Read the root message and replies from a specific Slack thread. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `authMethod` | string | No | Authentication method: oauth or bot_token | +| `botToken` | string | No | Bot token for Custom Bot | +| `channel` | string | Yes | Slack channel that contains the thread | +| `thread_ts` | string | Yes | Timestamp of the root message to read | +| `limit` | number | No | Number of thread messages to retrieve (default: 15, Slack currently limits non-Marketplace apps to max 15 per request) | +| `cursor` | string | No | Pagination cursor for fetching additional replies | +| `oldest` | string | No | Start of time range (timestamp) | +| `latest` | string | No | End of time range (timestamp) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `thread_ts` | string | Timestamp of the thread root message | +| `messages` | array | Array of thread messages (root + replies) | +| `has_more` | boolean | Indicates whether more replies can be fetched | +| `next_cursor` | string | Cursor for fetching the next page of replies | + ### `slack_download` Download a file from Slack diff --git a/apps/docs/content/docs/es/tools/slack.mdx b/apps/docs/content/docs/es/tools/slack.mdx index ebc4837645..8a6e58b2a4 100644 --- a/apps/docs/content/docs/es/tools/slack.mdx +++ b/apps/docs/content/docs/es/tools/slack.mdx @@ -110,7 +110,7 @@ Lee los últimos mensajes de los canales de Slack. Recupera el historial de conv | `authMethod` | string | No | Método de autenticación: oauth o bot_token | | `botToken` | string | No | Token del bot para Bot personalizado | | `channel` | string | Sí | Canal de Slack del que leer mensajes (p. ej., #general) | -| `limit` | number | No | Número de mensajes a recuperar (predeterminado: 10, máx: 100) | +| `limit` | number | No | Número de mensajes a recuperar (predeterminado: 10; Slack limita a 15 por solicitud para apps fuera del Marketplace) | | `oldest` | string | No | Inicio del rango de tiempo (marca de tiempo) | | `latest` | string | No | Fin del rango de tiempo (marca de tiempo) | @@ -120,6 +120,32 @@ Lee los últimos mensajes de los canales de Slack. Recupera el historial de conv | --------- | ---- | ----------- | | `messages` | array | Array de objetos de mensaje del canal | +### `slack_thread_reader` + +Lee el mensaje raíz y las respuestas de un hilo específico de Slack. + +#### Entrada + +| Parámetro | Tipo | Obligatorio | Descripción | +| --------- | ---- | -------- | ----------- | +| `authMethod` | string | No | Método de autenticación: oauth o bot_token | +| `botToken` | string | No | Token del bot para Bot personalizado | +| `channel` | string | Sí | Canal de Slack que contiene el hilo | +| `thread_ts` | string | Sí | Marca de tiempo del mensaje raíz que se quiere leer | +| `limit` | number | No | Número de mensajes del hilo a recuperar (predeterminado: 15; Slack limita a 15 por solicitud para apps fuera del Marketplace) | +| `cursor` | string | No | Cursor de paginación para obtener respuestas adicionales | +| `oldest` | string | No | Inicio del rango de tiempo (marca de tiempo) | +| `latest` | string | No | Fin del rango de tiempo (marca de tiempo) | + +#### Salida + +| Parámetro | Tipo | Descripción | +| --------- | ---- | ----------- | +| `thread_ts` | string | Marca de tiempo del mensaje raíz del hilo | +| `messages` | array | Array de mensajes del hilo (raíz + respuestas) | +| `has_more` | boolean | Indica si se pueden obtener más respuestas | +| `next_cursor` | string | Cursor para obtener la siguiente página de respuestas | + ### `slack_download` Descargar un archivo de Slack diff --git a/apps/docs/content/docs/fr/tools/slack.mdx b/apps/docs/content/docs/fr/tools/slack.mdx index ed62f77879..6c97a030aa 100644 --- a/apps/docs/content/docs/fr/tools/slack.mdx +++ b/apps/docs/content/docs/fr/tools/slack.mdx @@ -110,7 +110,7 @@ Lisez les derniers messages des canaux Slack. Récupérez l'historique des conve | `authMethod` | chaîne | Non | Méthode d'authentification : oauth ou bot_token | | `botToken` | chaîne | Non | Jeton du bot pour Bot personnalisé | | `channel` | chaîne | Oui | Canal Slack pour lire les messages \(ex. : #general\) | -| `limit` | nombre | Non | Nombre de messages à récupérer \(par défaut : 10, max : 100\) | +| `limit` | nombre | Non | Nombre de messages à récupérer \(par défaut : 10; Slack limite les apps hors Marketplace à 15 par requête\) | | `oldest` | chaîne | Non | Début de la plage temporelle \(horodatage\) | | `latest` | chaîne | Non | Fin de la plage temporelle \(horodatage\) | @@ -120,6 +120,32 @@ Lisez les derniers messages des canaux Slack. Récupérez l'historique des conve | --------- | ---- | ----------- | | `messages` | tableau | Tableau d'objets de messages du canal | +### `slack_thread_reader` + +Lisez le message racine et les réponses d'un thread Slack spécifique. + +#### Entrée + +| Paramètre | Type | Obligatoire | Description | +| --------- | ---- | ---------- | ----------- | +| `authMethod` | chaîne | Non | Méthode d'authentification : oauth ou bot_token | +| `botToken` | chaîne | Non | Jeton du bot pour Bot personnalisé | +| `channel` | chaîne | Oui | Canal Slack qui contient le thread | +| `thread_ts` | chaîne | Oui | Horodatage du message racine à lire | +| `limit` | nombre | Non | Nombre de messages du thread à récupérer (par défaut : 15; Slack limite les apps hors Marketplace à 15 par requête) | +| `cursor` | chaîne | Non | Curseur de pagination pour récupérer plus de réponses | +| `oldest` | chaîne | Non | Début de la plage temporelle (horodatage) | +| `latest` | chaîne | Non | Fin de la plage temporelle (horodatage) | + +#### Sortie + +| Paramètre | Type | Description | +| --------- | ---- | ----------- | +| `thread_ts` | chaîne | Horodatage du message racine du thread | +| `messages` | tableau | Tableau des messages du thread (racine + réponses) | +| `has_more` | booléen | Indique si d'autres réponses peuvent être récupérées | +| `next_cursor` | chaîne | Curseur pour récupérer la page suivante de réponses | + ### `slack_download` Télécharger un fichier depuis Slack diff --git a/apps/docs/content/docs/ja/tools/slack.mdx b/apps/docs/content/docs/ja/tools/slack.mdx index 156f8d19a8..0349ad4761 100644 --- a/apps/docs/content/docs/ja/tools/slack.mdx +++ b/apps/docs/content/docs/ja/tools/slack.mdx @@ -109,7 +109,7 @@ Slackチャンネルから最新のメッセージを読み取ります。フィ | `authMethod` | string | いいえ | 認証方法:oauthまたはbot_token | | `botToken` | string | いいえ | カスタムボット用のボットトークン | | `channel` | string | はい | メッセージを読み取るSlackチャンネル(例:#general) | -| `limit` | number | いいえ | 取得するメッセージ数(デフォルト:10、最大:100) | +| `limit` | number | いいえ | 取得するメッセージ数(デフォルト:10。Slackの制限によりMarketplace外アプリは1リクエストあたり15件まで) | | `oldest` | string | いいえ | 時間範囲の開始(タイムスタンプ) | | `latest` | string | いいえ | 時間範囲の終了(タイムスタンプ) | @@ -119,6 +119,32 @@ Slackチャンネルから最新のメッセージを読み取ります。フィ | --------- | ---- | ----------- | | `messages` | array | チャンネルからのメッセージオブジェクトの配列 | +### `slack_thread_reader` + +特定のSlackスレッドのルートメッセージと返信を読み取ります。 + +#### 入力 + +| パラメータ | 型 | 必須 | 説明 | +| --------- | ---- | -------- | ----------- | +| `authMethod` | string | いいえ | 認証方法:oauthまたはbot_token | +| `botToken` | string | いいえ | カスタムボット用のボットトークン | +| `channel` | string | はい | スレッドを含むSlackチャンネル | +| `thread_ts` | string | はい | 読み取るルートメッセージのタイムスタンプ | +| `limit` | number | いいえ | 取得するスレッドメッセージ数(デフォルト:15。Slackの制限によりMarketplace外アプリは1リクエストあたり15件まで) | +| `cursor` | string | いいえ | 追加の返信を取得するためのカーソル | +| `oldest` | string | いいえ | 時間範囲の開始(タイムスタンプ) | +| `latest` | string | いいえ | 時間範囲の終了(タイムスタンプ) | + +#### 出力 + +| パラメータ | 型 | 説明 | +| --------- | ---- | ----------- | +| `thread_ts` | string | スレッドのルートメッセージのタイムスタンプ | +| `messages` | array | スレッドのメッセージ(ルート + 返信)の配列 | +| `has_more` | boolean | さらに返信を取得できるかどうかを示します | +| `next_cursor` | string | 次の返信ページを取得するためのカーソル | + ### `slack_download` Slackからファイルをダウンロードする diff --git a/apps/docs/content/docs/zh/tools/slack.mdx b/apps/docs/content/docs/zh/tools/slack.mdx index db31fc4d3d..1046d49760 100644 --- a/apps/docs/content/docs/zh/tools/slack.mdx +++ b/apps/docs/content/docs/zh/tools/slack.mdx @@ -108,7 +108,7 @@ import { BlockInfoCard } from "@/components/ui/block-info-card" | `authMethod` | string | 否 | 认证方法:oauth 或 bot_token | | `botToken` | string | 否 | 自定义 Bot 的 Bot token | | `channel` | string | 是 | 要读取消息的 Slack 频道(例如:#general) | -| `limit` | number | 否 | 要检索的消息数量(默认:10,最大:100) | +| `limit` | number | 否 | 要检索的消息数量(默认:10;Slack 限制非 Marketplace 应用每次请求最多 15 条) | | `oldest` | string | 否 | 时间范围的开始(时间戳) | | `latest` | string | 否 | 时间范围的结束(时间戳) | @@ -118,6 +118,32 @@ import { BlockInfoCard } from "@/components/ui/block-info-card" | --------- | ---- | ----------- | | `messages` | array | 频道中的消息对象数组 | +### `slack_thread_reader` + +读取特定 Slack 线程的根消息及所有回复。 + +#### 输入 + +| 参数 | 类型 | 必需 | 描述 | +| --------- | ---- | -------- | ----------- | +| `authMethod` | string | 否 | 认证方式:oauth 或 bot_token | +| `botToken` | string | 否 | 自定义 Bot 的 token | +| `channel` | string | 是 | 包含该线程的 Slack 频道 | +| `thread_ts` | string | 是 | 需要读取的根消息时间戳 | +| `limit` | number | 否 | 要检索的线程消息数(默认:15;Slack 限制非 Marketplace 应用每次请求最多 15 条) | +| `cursor` | string | 否 | 获取更多回复的分页游标 | +| `oldest` | string | 否 | 时间范围开始(时间戳) | +| `latest` | string | 否 | 时间范围结束(时间戳) | + +#### 输出 + +| 参数 | 类型 | 描述 | +| --------- | ---- | ----------- | +| `thread_ts` | string | 线程根消息的时间戳 | +| `messages` | array | 线程消息(根消息 + 回复)的数组 | +| `has_more` | boolean | 指示是否还有更多回复可获取 | +| `next_cursor` | string | 获取下一页回复的游标 | + ### `slack_download` 从 Slack 下载文件 diff --git a/apps/sim/blocks/blocks/slack.ts b/apps/sim/blocks/blocks/slack.ts index a78c939fef..9b54edb853 100644 --- a/apps/sim/blocks/blocks/slack.ts +++ b/apps/sim/blocks/blocks/slack.ts @@ -26,6 +26,7 @@ export const SlackBlock: BlockConfig = { { label: 'Send Message', id: 'send' }, { label: 'Create Canvas', id: 'canvas' }, { label: 'Read Messages', id: 'read' }, + { label: 'Read Thread', id: 'read_thread' }, { label: 'Download File', id: 'download' }, { label: 'Update Message', id: 'update' }, { label: 'Delete Message', id: 'delete' }, @@ -176,7 +177,7 @@ export const SlackBlock: BlockConfig = { placeholder: '15', condition: { field: 'operation', - value: 'read', + value: ['read', 'read_thread'], }, }, { @@ -186,7 +187,39 @@ export const SlackBlock: BlockConfig = { placeholder: 'ISO 8601 timestamp', condition: { field: 'operation', - value: 'read', + value: ['read', 'read_thread'], + }, + }, + { + id: 'latest', + title: 'Latest Timestamp', + type: 'short-input', + placeholder: 'ISO 8601 timestamp', + condition: { + field: 'operation', + value: ['read', 'read_thread'], + }, + }, + { + id: 'threadReaderTs', + title: 'Thread Timestamp', + type: 'short-input', + canonicalParamId: 'thread_ts', + placeholder: 'Root message timestamp (e.g., 1405894322.002768)', + condition: { + field: 'operation', + value: 'read_thread', + }, + required: true, + }, + { + id: 'threadCursor', + title: 'Pagination Cursor', + type: 'short-input', + placeholder: 'Slack cursor for fetching more replies', + condition: { + field: 'operation', + value: 'read_thread', }, }, // Download File specific fields @@ -281,6 +314,7 @@ export const SlackBlock: BlockConfig = { 'slack_message', 'slack_canvas', 'slack_message_reader', + 'slack_thread_reader', 'slack_download', 'slack_update_message', 'slack_delete_message', @@ -295,6 +329,8 @@ export const SlackBlock: BlockConfig = { return 'slack_canvas' case 'read': return 'slack_message_reader' + case 'read_thread': + return 'slack_thread_reader' case 'download': return 'slack_download' case 'update': @@ -320,14 +356,17 @@ export const SlackBlock: BlockConfig = { content, limit, oldest, + latest, attachmentFiles, files, threadTs, + threadReaderTs, updateTimestamp, updateText, deleteTimestamp, reactionTimestamp, emojiName, + threadCursor, ...rest } = params @@ -384,15 +423,29 @@ export const SlackBlock: BlockConfig = { break case 'read': + case 'read_thread': if (limit) { const parsedLimit = Number.parseInt(limit, 10) baseParams.limit = !Number.isNaN(parsedLimit) ? parsedLimit : 10 } else { - baseParams.limit = 10 + baseParams.limit = operation === 'read_thread' ? 20 : 10 } if (oldest) { baseParams.oldest = oldest } + if (latest) { + baseParams.latest = latest + } + if (operation === 'read_thread') { + const threadTimestamp = threadReaderTs || threadTs + if (!threadTimestamp) { + throw new Error('Thread timestamp is required to read a thread') + } + baseParams.thread_ts = threadTimestamp + if (threadCursor) { + baseParams.cursor = threadCursor + } + } break case 'download': { @@ -450,6 +503,8 @@ export const SlackBlock: BlockConfig = { content: { type: 'string', description: 'Canvas content' }, limit: { type: 'string', description: 'Message limit' }, oldest: { type: 'string', description: 'Oldest timestamp' }, + latest: { type: 'string', description: 'Latest timestamp for message/thread reads' }, + threadCursor: { type: 'string', description: 'Slack cursor for paginating thread replies' }, fileId: { type: 'string', description: 'File ID to download' }, downloadFileName: { type: 'string', description: 'File name override for download' }, // Update/Delete/React operation inputs @@ -462,6 +517,7 @@ export const SlackBlock: BlockConfig = { name: { type: 'string', description: 'Emoji name' }, threadTs: { type: 'string', description: 'Thread timestamp' }, thread_ts: { type: 'string', description: 'Thread timestamp for reply' }, + threadReaderTs: { type: 'string', description: 'Thread timestamp for reading thread' }, }, outputs: { // slack_message outputs (send operation) diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index f22d04cd20..7c78144f97 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -788,6 +788,7 @@ import { slackDownloadTool, slackMessageReaderTool, slackMessageTool, + slackThreadReaderTool, slackUpdateMessageTool, } from '@/tools/slack' import { smsSendTool } from '@/tools/sms' @@ -1051,6 +1052,7 @@ export const tools: Record = { jira_remove_watcher: jiraRemoveWatcherTool, slack_message: slackMessageTool, slack_message_reader: slackMessageReaderTool, + slack_thread_reader: slackThreadReaderTool, slack_canvas: slackCanvasTool, slack_download: slackDownloadTool, slack_update_message: slackUpdateMessageTool, diff --git a/apps/sim/tools/slack/index.ts b/apps/sim/tools/slack/index.ts index 479520fbc8..83280dee3e 100644 --- a/apps/sim/tools/slack/index.ts +++ b/apps/sim/tools/slack/index.ts @@ -4,12 +4,14 @@ import { slackDeleteMessageTool } from '@/tools/slack/delete_message' import { slackDownloadTool } from '@/tools/slack/download' import { slackMessageTool } from '@/tools/slack/message' import { slackMessageReaderTool } from '@/tools/slack/message_reader' +import { slackThreadReaderTool } from '@/tools/slack/thread_reader' import { slackUpdateMessageTool } from '@/tools/slack/update_message' export { slackMessageTool, slackCanvasTool, slackMessageReaderTool, + slackThreadReaderTool, slackDownloadTool, slackUpdateMessageTool, slackDeleteMessageTool, diff --git a/apps/sim/tools/slack/thread_reader.ts b/apps/sim/tools/slack/thread_reader.ts new file mode 100644 index 0000000000..292771ebe8 --- /dev/null +++ b/apps/sim/tools/slack/thread_reader.ts @@ -0,0 +1,182 @@ +import type { SlackThreadReaderParams, SlackThreadReaderResponse } from '@/tools/slack/types' +import type { ToolConfig } from '@/tools/types' + +export const slackThreadReaderTool: ToolConfig = + { + id: 'slack_thread_reader', + name: 'Slack Thread Reader', + description: + 'Read the full contents of a Slack thread, including the root message and its replies.', + version: '1.0.0', + + oauth: { + required: true, + provider: 'slack', + }, + + params: { + authMethod: { + type: 'string', + required: false, + visibility: 'user-only', + description: 'Authentication method: oauth or bot_token', + }, + botToken: { + type: 'string', + required: false, + visibility: 'user-only', + description: 'Bot token for Custom Bot', + }, + accessToken: { + type: 'string', + required: false, + visibility: 'hidden', + description: 'OAuth access token or bot token for Slack API', + }, + channel: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Slack channel containing the thread (e.g., #support)', + }, + thread_ts: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Timestamp of the thread root message', + }, + limit: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of thread messages to retrieve (default: 20, max: 100)', + }, + cursor: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Pagination cursor for fetching additional thread messages', + }, + oldest: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Start of time range (timestamp)', + }, + latest: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'End of time range (timestamp)', + }, + }, + + request: { + url: (params: SlackThreadReaderParams) => { + const url = new URL('https://slack.com/api/conversations.replies') + url.searchParams.append('channel', params.channel) + url.searchParams.append('ts', params.thread_ts) + + const limit = params.limit ? Number(params.limit) : 20 + url.searchParams.append('limit', String(Math.min(limit, 15))) + + if (params.cursor) { + url.searchParams.append('cursor', params.cursor) + } + if (params.oldest) { + url.searchParams.append('oldest', params.oldest) + } + if (params.latest) { + url.searchParams.append('latest', params.latest) + } + + return url.toString() + }, + method: 'GET', + headers: (params: SlackThreadReaderParams) => ({ + 'Content-Type': 'application/json', + Authorization: `Bearer ${params.accessToken || params.botToken}`, + }), + }, + + transformResponse: async ( + response: Response, + params?: SlackThreadReaderParams + ): Promise => { + const data = await response.json() + + const messages = (data.messages || []).map((message: any) => ({ + ts: message.ts, + text: message.text || '', + user: message.user || message.bot_id || 'unknown', + type: message.type || 'message', + subtype: message.subtype, + thread_ts: message.thread_ts, + parent_user_id: message.parent_user_id, + files: message.files?.map((file: any) => ({ + id: file.id, + name: file.name, + mimetype: file.mimetype, + size: file.size, + url_private: file.url_private, + })), + })) + + return { + success: true, + output: { + thread_ts: + params?.thread_ts || data.ts || messages[0]?.thread_ts || messages[0]?.ts || '', + messages, + has_more: data.has_more, + next_cursor: data.response_metadata?.next_cursor, + }, + } + }, + + outputs: { + thread_ts: { + type: 'string', + description: 'Timestamp of the thread root message used for retrieval', + }, + messages: { + type: 'array', + description: 'Array of messages (root + replies) from the thread', + items: { + type: 'object', + properties: { + ts: { type: 'string' }, + text: { type: 'string' }, + user: { type: 'string' }, + type: { type: 'string' }, + subtype: { type: 'string' }, + thread_ts: { type: 'string' }, + parent_user_id: { type: 'string' }, + files: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'string' }, + name: { type: 'string' }, + mimetype: { type: 'string' }, + size: { type: 'number' }, + url_private: { type: 'string' }, + }, + }, + }, + }, + }, + }, + has_more: { + type: 'boolean', + description: 'Whether additional thread messages can be fetched with the next cursor', + optional: true, + }, + next_cursor: { + type: 'string', + description: 'Cursor to use for fetching the next page of thread replies', + optional: true, + }, + }, + } diff --git a/apps/sim/tools/slack/types.ts b/apps/sim/tools/slack/types.ts index 4737f49639..d3daced74c 100644 --- a/apps/sim/tools/slack/types.ts +++ b/apps/sim/tools/slack/types.ts @@ -27,6 +27,15 @@ export interface SlackMessageReaderParams extends SlackBaseParams { latest?: string } +export interface SlackThreadReaderParams extends SlackBaseParams { + channel: string + thread_ts: string + limit?: number + cursor?: string + oldest?: string + latest?: string +} + export interface SlackDownloadParams extends SlackBaseParams { fileId: string fileName?: string @@ -161,6 +170,30 @@ export interface SlackMessageReaderResponse extends ToolResponse { } } +export interface SlackThreadReaderResponse extends ToolResponse { + output: { + thread_ts: string + messages: Array<{ + ts: string + text: string + user: string + type: string + subtype?: string + thread_ts?: string + parent_user_id?: string + files?: Array<{ + id: string + name: string + mimetype: string + size: number + url_private?: string + }> + }> + has_more?: boolean + next_cursor?: string + } +} + export interface SlackDownloadResponse extends ToolResponse { output: { file: { @@ -210,6 +243,7 @@ export interface SlackAddReactionResponse extends ToolResponse { export type SlackResponse = | SlackCanvasResponse | SlackMessageReaderResponse + | SlackThreadReaderResponse | SlackMessageResponse | SlackDownloadResponse | SlackUpdateMessageResponse