Skip to content

Find a time that works for several agents and people

Finding a time for one calendar is easy. The hard part is a time that suits several agents and the people behind them, without anyone reading anyone else’s calendar. Chronary does this in one call: you name the agents, and it returns only the times when all of them are free.

In this tutorial you will:

  1. Ask for times when several agents, and a shared room, are all free.
  2. Let a person’s own Google or Outlook calendar block time too, without sharing its details.
  3. Book the chosen time on every calendar, safely.
  4. Hand the choice to the agents when they need to agree on a time.

You need two or more agents, each with a calendar, the SDK installed and CHRONARY_API_KEY set. Give your AI agent a calendar shows how to create them. The examples use three agents and one shared calendar for a meeting room:

import { Chronary } from '@chronary/sdk';
const chronary = new Chronary();
const agents = ['agt_sales', 'agt_support', 'agt_engineering'];
const roomCalendarId = 'cal_meeting_room';

Ask for one-hour slots over the next five days. Chronary checks every calendar of every agent you name, plus any extra calendars you list (here, the room), and returns only the times when all of them are free.

const now = new Date();
const fiveDays = new Date(now.getTime() + 5 * 24 * 60 * 60 * 1000);
const result = await chronary.availability.check({
agents,
calendars: [roomCalendarId],
start: now.toISOString(),
end: fiveDays.toISOString(),
duration: '1h',
});
console.log(result.availability_state, result.slots.slice(0, 3));

Each slot is a stretch of at least an hour when everyone is free, and it can be longer. Each agent’s working hours count too: if you set availability rules on their calendars, time outside those hours is busy. So a slot here falls inside everyone’s working day.

Agents usually act for people, and those people already have meetings in Google Calendar or Outlook. Connect a person’s calendar, and their real meetings block time for their agent automatically. The agent only ever sees “busy” or “free”. Chronary never shows it event titles, attendees or the account name.

The agent can’t sign in for the person, so it creates a setup link and sends it to them. The person opens it, signs in to Google or Microsoft, and picks which of their calendars count.

const link = await chronary.connectionLinks.create('cal_sales', {
capabilities: ['availability'],
});
// Send this to the person, for example by email or chat.
console.log(link.setup_url);
// Later: check whether they finished.
const status = await chronary.connectionLinks.get(link.id);
console.log(status.status); // 'awaiting_human' … 'completed'

Once it’s connected, the call in step 1 includes that person’s busy time with no change to your code.

Chronary keeps a copy of each person’s busy times and refreshes it in the background. If a copy is out of date, Chronary doesn’t guess. availability_state is something other than complete, slots is empty and warnings says why. Wait and ask again rather than book a time that might be taken:

if (result.availability_state !== 'complete') {
console.warn(result.warnings.map((w) => w.message).join('; '));
// Try again in a minute, or ask the person to reconnect.
}

Pick a slot, then add the meeting to each agent’s calendar and the room. If those calendars have prevent_overlaps on, a booking that clashes with something added in the meantime is refused with 409 event_conflict, and you can pick the next slot. The booking tutorial shows that retry loop.

const slot = result.slots[0];
const start = new Date(slot.start);
const end = new Date(start.getTime() + 60 * 60 * 1000);
const calendarIds = ['cal_sales', 'cal_support', 'cal_engineering', roomCalendarId];
for (const calendarId of calendarIds) {
await chronary.events.create(calendarId, {
title: 'Quarterly planning',
start_time: start.toISOString(),
end_time: end.toISOString(),
metadata: { meeting: 'quarterly-planning' },
});
}

The shared metadata value lets you find all copies later, to move or cancel them together.

Sometimes one agent shouldn’t decide for everyone. Each participant may have its own rules and priorities. A scheduling proposal lets one agent offer a few times, and each participant accepts, declines or suggests another. When everyone has answered, the organizer resolves it and Chronary books the agreed time.

const MEETING_MS = 60 * 60 * 1000;
const options = result.slots.slice(0, 3).map((s) => ({
start_time: s.start,
end_time: new Date(new Date(s.start).getTime() + MEETING_MS).toISOString(),
}));
const proposal = await chronary.scheduling.create({
title: 'Quarterly planning',
organizer_agent_id: 'agt_sales',
participant_agent_ids: ['agt_support', 'agt_engineering'],
calendar_id: 'cal_sales',
slots: options,
});

The multi-agent scheduling guide walks through responding, counter-offers and resolving.

Agents connected through the MCP server do the same with the find_meeting_time tool. In Claude, for example: “Find an hour this week when Sales, Support and Engineering are all free.”

Your agents can now find a time that suits all of them and the people behind them, without anyone seeing anyone else’s calendar, and book it everywhere safely.