Ai-Mee Help Centre
Home
Features
How-To Guides
FAQ
Need Help?
Home
Features
How-To Guides
FAQ
Need Help?

Step 5 — Update Bot Tools

File: api/src/bot/tools.ts
Prerequisites: Step 2 — Posts Service, Step 3 — Clients Service


What This Does

Updates four bot tool descriptions and one return value to reflect that scheduling now operates on customer_platform_post.scheduled_at rather than customer_posts.scheduled. No logic changes are needed — the tools call the service functions which were already updated in Steps 2 and 3.


5.1 — Update list_posts description

Find:

      name: 'list_posts',
      description:
        'List posts for a client with optional status filter. Returns id, title, platforms, status, scheduled date, and created_at.',

Replace with:

      name: 'list_posts',
      description:
        'List posts for a client with optional status filter. Returns id, title, platforms, status, and created_at.',

5.2 — Update list_scheduled_posts description

Find:

      name: 'list_scheduled_posts',
      description:
        'List all upcoming scheduled posts across every active client belonging to the authenticated user.',

Replace with:

      name: 'list_scheduled_posts',
      description:
        'List all upcoming scheduled platform posts across every active client belonging to the authenticated user. Returns per-platform scheduled_at times.',

5.3 — Update schedule_post description

Find:

      name: 'schedule_post',
      description:
        "Set a scheduled publish time for an approved post. Post must be in 'approved' status.",
      schema: z.object({
        post_id: z.number().int().positive().describe('Post ID to schedule'),
        scheduled_at: z
          .string()
          .describe(
            'ISO 8601 date-time string for when to publish, e.g. "2026-04-01T10:00:00Z". Must be in the future.'
          ),
      }),

Replace with:

      name: 'schedule_post',
      description:
        "Set a scheduled publish time for an approved post. Sets scheduled_at on all platform posts for this post. Post must be in 'approved' status.",
      schema: z.object({
        post_id: z.number().int().positive().describe('Post ID to schedule'),
        scheduled_at: z
          .string()
          .describe(
            'ISO 8601 date-time string for when to publish all platforms, e.g. "2026-04-01T10:00:00Z". Must be in the future.'
          ),
      }),

5.4 — Update schedule_multiple_posts description

Find:

      name: 'schedule_multiple_posts',
      description:
        'Schedule multiple approved posts at once. Use instead of calling schedule_post in a loop. ' +
        'Accepts a JSON string array of {post_id, scheduled_at} objects.',
      schema: z.object({
        schedules: z
          .string()
          .describe(
            'JSON array of schedule items, e.g. \'[{"post_id": 1, "scheduled_at": "2026-04-01T10:00:00Z"}]\''
          ),
      }),

Replace with:

      name: 'schedule_multiple_posts',
      description:
        'Schedule multiple approved posts at once. Sets scheduled_at on all platform posts for each parent post. Use instead of calling schedule_post in a loop. ' +
        'Accepts a JSON string array of {post_id, scheduled_at} objects.',
      schema: z.object({
        schedules: z
          .string()
          .describe(
            'JSON array of schedule items, e.g. \'[{"post_id": 1, "scheduled_at": "2026-04-01T10:00:00Z"}]\''
          ),
      }),

5.5 — Verify

cd api
pnpm build
# No TypeScript errors

✅ Done

Proceed to Step 6 — Frontend Types & Store.