Skip to main content
Glama
oregpt
by oregpt

conversations_replies

Retrieve all messages from a specific Slack thread using channel ID and thread timestamp. Supports pagination for handling long conversations and includes optional system message filtering.

Instructions

Fetches all messages in a specific thread by channel and thread timestamp. Supports pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTokenYesSlack OAuth token (xoxp-... or xoxb-...)
channel_idYesChannel ID (e.g., C1234567890), channel name (#general), or DM (@username)
thread_tsYesMessage timestamp in format 1234567890.123456
limitNoTime range (1d, 7d, 1m, 90d) or message count (e.g., 100)
cursorNoPagination cursor from previous response
include_activity_messagesNoInclude join/leave system messages (default: false)

Implementation Reference

  • Main handler function implementing the conversations_replies tool. Validates input, resolves channel ID, fetches thread replies using Slack's conversations.replies API, filters messages, and handles errors.
    export async function conversationsReplies(args: any): Promise<ToolResponse> { try { const validated = ConversationsRepliesSchema.parse(args); const client = new WebClient(validated.accessToken); console.log('Fetching thread replies for channel:', validated.channel_id, 'thread:', validated.thread_ts); // Resolve channel name/username to ID if needed const channelId = await resolveChannelId(client, validated.channel_id); // Parse limit parameter const limitParams = parseLimit(validated.limit); // Fetch thread replies const result = await client.conversations.replies({ channel: channelId, ts: validated.thread_ts, cursor: validated.cursor, ...limitParams }); // Filter out activity messages if not requested let messages = result.messages || []; if (!validated.include_activity_messages) { messages = messages.filter((msg: any) => !msg.subtype || !['channel_join', 'channel_leave'].includes(msg.subtype)); } return { success: true, data: { messages, has_more: result.has_more, cursor: result.response_metadata?.next_cursor, channel_id: channelId, thread_ts: validated.thread_ts } }; } catch (error: any) { if (error.name === 'ZodError') { return { success: false, error: `Validation error: ${error.errors.map((e: any) => e.message).join(', ')}` }; } return handleSlackError(error); }
  • Zod schema defining the input parameters and types for the conversations_replies tool.
    export const ConversationsRepliesSchema = z.object({ accessToken: z.string().describe("Slack OAuth token (xoxp-... or xoxb-...)"), channel_id: z.string().describe("Channel ID (e.g., C1234567890), channel name (#general), or DM (@username)"), thread_ts: z.string().describe("Message timestamp in format 1234567890.123456"), limit: z.union([z.string(), z.number()]).optional().describe("Time range (1d, 7d, 1m, 90d) or message count (e.g., 100)"), cursor: z.string().optional().describe("Pagination cursor from previous response"), include_activity_messages: z.boolean().optional().describe("Include join/leave system messages (default: false)") });
  • src/index.ts:100-104 (registration)
    Tool registration in the listTools handler, defining name, description, and input schema for conversations_replies.
    { name: 'conversations_replies', description: 'Fetches all messages in a specific thread by channel and thread timestamp. Supports pagination.', inputSchema: zodToMCPSchema(ConversationsRepliesSchema) },
  • src/index.ts:133-135 (registration)
    Dispatch registration in the callTool handler switch statement that invokes the conversationsReplies function.
    case 'conversations_replies': result = await conversationsReplies(args); break;
  • Helper function parseLimit used in conversationsReplies to handle limit parameter as time range or count.
    function parseLimit(limit?: string | number): { oldest?: string; limit?: number } { if (!limit) { return { limit: 100 }; // Default } if (typeof limit === 'number') { return { limit }; } // Parse time ranges: 1d, 7d, 1m, 90d const timeMatch = limit.match(/^(\d+)(d|m)$/); if (timeMatch) { const value = parseInt(timeMatch[1]); const unit = timeMatch[2]; const now = Date.now(); let seconds = 0; if (unit === 'd') { seconds = value * 24 * 60 * 60; } else if (unit === 'm') { seconds = value * 30 * 24 * 60 * 60; } const oldest = ((now - seconds * 1000) / 1000).toString(); return { oldest }; } // If not a time range, treat as count const count = parseInt(limit); if (!isNaN(count)) { return { limit: count }; } return { limit: 100 }; // Default fallback }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/oregpt/Agenticledger_MCP_Slack'

If you have feedback or need assistance with the MCP directory API, please join our Discord server