get_channel_history
Retrieve message history from Slack channels by specifying channel ID, time range, and message limits to analyze conversations and track discussions.
Instructions
Get message history from a channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | Channel ID | |
| limit | No | Maximum number of messages to return | |
| oldest | No | Start of time range (timestamp) | |
| latest | No | End of time range (timestamp) |
Implementation Reference
- src/tools/messages.ts:66-84 (handler)The handler function implementing the get_channel_history tool logic. It validates input with Zod schema, calls Slack's conversations.history API, and returns formatted messages with pagination info.export async function getChannelHistory(client: SlackClientWrapper, args: unknown) { const params = getChannelHistorySchema.parse(args); return await client.safeCall(async () => { const result = await client.getClient().conversations.history({ channel: params.channel, limit: params.limit, oldest: params.oldest, latest: params.latest, cursor: params.cursor, }); return { messages: result.messages || [], has_more: result.has_more, next_cursor: result.response_metadata?.next_cursor, }; }); }
- src/utils/validators.ts:64-70 (schema)Zod schema defining and validating the input parameters for the get_channel_history tool, including channel ID, optional limit, time ranges, and cursor.export const getChannelHistorySchema = z.object({ channel: channelIdSchema, limit: z.number().min(1).max(1000).optional().default(100), oldest: timestampSchema.optional(), latest: timestampSchema.optional(), cursor: z.string().optional(), });
- src/index.ts:236-263 (registration)Registration of the get_channel_history tool in the list_tools response, providing name, description, and JSON input schema.name: 'get_channel_history', description: 'Get message history from a channel', inputSchema: { type: 'object', properties: { channel: { type: 'string', description: 'Channel ID', }, limit: { type: 'number', description: 'Maximum number of messages to return', default: 100, minimum: 1, maximum: 1000, }, oldest: { type: 'string', description: 'Start of time range (timestamp)', }, latest: { type: 'string', description: 'End of time range (timestamp)', }, }, required: ['channel'], }, },
- src/index.ts:429-429 (registration)Binding of the get_channel_history tool name to its handler function in the toolHandlers map for call_tool requests.get_channel_history: (args) => messageTools.getChannelHistory(slackClient, args),