Appointments
Appointments is a task pack that finds open times and books, moves, and cancels the
caller’s appointments against your calendar, which you supply as functions. Add it to
an Operations or a ServiceAgent with add_to().
Each slot and appointment comes with a label, which is how it’s said (“Tuesday the 3rd
at 2 pm”). The pack never reads or writes a date itself, so the time zone, the calendar,
and the language stay yours. Only a slot the pack found open can be booked, and every
booking, move, and cancellation is read back for the caller’s yes.
Parameters
All parameters are keyword-only. Every function may be async.
openings
book
book(call, slot, kind, note) books the slot once the caller says yes. Raise
WriteFailed when the calendar refuses.
booked
booked(call) returns the caller’s Appointments. Needed for move and cancel.
move
move(call, appointment, slot) moves one. Raises ValueError without booked.
cancel
cancel(call, appointment) cancels one. Raises ValueError without booked.
kinds
What an appointment can be for, as the caller would say it (“cleaning”). None gives
no choice.
before_identity
True to find openings and book before the caller is identified, for new customers.
The caller’s own appointments always need an identified account.
wording
Replacements keyed like APPOINTMENTS_WORDING. See wording.
tools
New names for the generated tools, by key. An unknown key raises ValueError.
state_key
Where in call.state the pack keeps the slots it found.
Properties
tools
The generated tools’ names, by key.
Methods
add_to(target) registers the pack’s lookups and operations on an Operations or a
ServiceAgent, and returns target.
Slot and Appointment
Frozen dataclasses your calendar functions return and receive.
Slot.id
The calendar’s id for an open time.
Slot.label
How the time is said, in the calendar’s own time zone and words.
Appointment.id
The calendar’s id for one of the caller’s appointments.
Appointment.label
How the appointment is said: “your cleaning on Tuesday the 3rd at 2 pm”.
Example
FrontDeskAgent and PersonalAssistantAgent take an Appointments
pack as appointments=.