# Bookings

Somebody books an intro call. sumwerk creates the lead, adds the person, makes the host the owner,
writes a note with the answers from the booking form, and puts a task on the host's list for that
day. A cancellation closes the task and says why; a reschedule moves it. The new lead sets your
automations in motion like any other, so research and a message to your team can follow by
themselves.

## What you need

- An **owner or developer** of your sumwerk account.
- **cal.com**: any plan; webhooks are in its settings.
- **Calendly**: a paid plan; Calendly creates webhooks only through its API, and sumwerk does that
  for you with a personal access token you paste once.

## cal.com

1. Account → Integrations → **Bookings**: copy the cal.com address.
2. In cal.com: Settings → Developer → Webhooks → **New webhook**. Subscriber URL: the address.
   Triggers: *Booking created*, *Booking rescheduled*, *Booking cancelled*. Secret: make one up.
3. Back in sumwerk, paste the same secret under cal.com and click **Connect cal.com**.

## Calendly

1. In Calendly: Integrations → API & webhooks → **Personal access tokens** → generate one.
2. Account → Integrations → **Bookings**: paste it under Calendly and click **Connect Calendly**.
   sumwerk reads your organization, creates the webhook subscription for *invitee created* and
   *invitee cancelled* with a signing key of its own, and forgets the token. You can delete the
   token in Calendly afterwards.

## How a booking is filed

- **The lead**: the person's email address is looked for on your customers and their people. Found:
  the booking lands there. Not found: a customer with the same company domain (never a free mail
  domain). Still nothing: a new lead, named after the *Company* answer if your form asks for one,
  else after the domain. It has its sumwerk UUID `id`, with no application ID yet. When the
  organization signs up later, explicitly link its application ID to that verified customer
  before using source-scoped PUT; a name or email alone is not identity evidence.
- **The person**: the invitee, as a contact with name and email.
- **The owner**: the host, matched to a team member by email address. If the host has no login
  here, the fallback owner you chose. An owner already set stays.
- **Team calls**: a round-robin event names the host Calendly assigned, and it works as above. A
  collective event, and a cal.com team event, name several hosts: every host with a login here gets
  the task, the first of them owns the lead, and the note names them all. A cancellation closes
  every host's task.
- **A tag** on every lead that booked, `intro-call` unless you change it.
- **A note**: event type, time in your time zone, host, every question and answer. For Calendly a
  link to the booking.
- **A task** for the owner, "Intro call with Jane Doe", due on the day of the call. Rescheduled: the
  task moves and is marked "Moved". Cancelled: the task is closed, marked "Cancelled", and a note
  says why.
- The lead's attributes get `lead_source` (`calendly` or `calcom`), `last_booking_at` and
  `booking_event_type`, so the customer list can be narrowed by them.

## What you can watch

Under the Bookings card, **Requests from cal.com** and **Requests from Calendly** list every call to
your addresses with the status sumwerk answered and why: accepted and what it did, dropped because
the event is not a booking, refused because the signature was not valid. Account → Log shows the
new leads next to everything else that came in.

## Switching off

**Disconnect** under the provider forgets the secret here. Remove the webhook in the tool as well,
otherwise it keeps calling and every call is refused.
