list-conversations-from-last-week
Retrieve recent Intercom conversations from the past 7 days to review customer interactions and support activity.
Instructions
Fetch all conversations from the last week (last 7 days)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/conversations.ts:73-99 (handler)Core implementation of the tool: calculates timestamps for the past 7 days and searches conversations using createdAt > startTimestamp and updatedAt < endTimestamp via IntercomClient.export async function listConversationsFromLastWeek() { // Calculate last week's date range const client = new IntercomClient(); const now = new Date(); const lastWeekStart = new Date(now); lastWeekStart.setDate(now.getDate() - 7); lastWeekStart.setHours(0, 0, 0, 0); const lastWeekEnd = new Date(lastWeekStart); lastWeekEnd.setDate(lastWeekStart.getDate() + 6); lastWeekEnd.setHours(23, 59, 59, 999); // Convert to Unix timestamp (seconds) const startTimestamp = Math.floor(lastWeekStart.getTime() / 1000); const endTimestamp = Math.floor(lastWeekEnd.getTime() / 1000); return client.searchConversations({ createdAt: { operator: ">", value: startTimestamp, }, updatedAt: { operator: "<", value: endTimestamp, }, }); }
- src/index.ts:24-28 (registration)Tool registration in MCP server capabilities, defining name, description, input schema (empty object), and output schema."list-conversations-from-last-week": { description: "Fetch all conversations from the last week (last 7 days)", inputSchema: z.object({}), outputSchema: z.any(), },
- src/index.ts:139-163 (handler)Dispatch logic in CallToolRequest handler that calls the listConversationsFromLastWeek function and formats the response as MCP content or error.if (name === "list-conversations-from-last-week") { try { const conversations = await listConversationsFromLastWeek(); return { content: [ { type: "text", text: JSON.stringify(conversations, null, 2), }, ], }; } catch (error) { if (error instanceof Error) { return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } throw error; } }
- src/index.ts:93-99 (registration)Tool listed in the ListTools response with name, description, and input schema.name: "list-conversations-from-last-week", description: "Fetch all conversations from the last week (last 7 days)", inputSchema: { type: "object", properties: {}, }, },