# Start a workflow from Calendly events

> Run a workflow when Calendly reports a booked or canceled meeting, a no-show, or a routing form submission, with a Webhook block set to Calendly.

To run a workflow when Calendly reports a booked or canceled meeting, a no-show, or a routing form submission, add a **Webhook** block whose **Source** is **Calendly** and give its URL to a Calendly webhook subscription. Calendly posts one event per request. Each event starts its own run.

Calendly has no settings page for webhooks. You create a webhook subscription with one request to Calendly's API, so you need a Calendly access token that is allowed to create webhook subscriptions, and a tool that can send that request. You also need edit access to the workflow's project.

## Add the Webhook block and generate its URL

1. In a draft workflow, add a **Webhook** block. The block palette also lists **Calendly webhook** in the **Start** group, which adds the block with its source already set.
2. Under **Source**, choose **Calendly**. The line under the setting reads "Verifies the signature · one run per event".
3. Under **Webhook URL**, select **Generate URL**, then copy the URL.

The badge beside the URL reads "Runs start after publish". The URL contains a token, and anyone who has the URL can send requests to it. Keep it out of shared documents.

## Create the webhook subscription in Calendly

Calendly does not issue a secret for a subscription. You choose a signing key and send it in the request that creates the subscription. Make it long and random, and keep a copy until the next section.

Send a `POST` request to the `/webhook_subscriptions` path of Calendly's API, with your access token, and with these fields in its JSON body:

| Field | What to send |
| --- | --- |
| `url` | The URL you copied. |
| `events` | The list of event types Calendly sends to this URL, such as `invitee.created`. |
| `organization` | The address Calendly's API gives your organization. |
| `scope` | `organization`, `user`, or `group`: whose events the subscription covers. A scope of `user` or `group` also needs a `user` or `group` field that says which one. |
| `signing_key` | The signing key you chose. |

Calendly's API marks `signing_key` as optional. Send it anyway: without it Calendly signs nothing, and the block has nothing to check.

Calendly allows `routing_form_submission.created` only on a subscription whose scope is `organization`, and only on a plan that includes routing forms. Create a separate subscription for it if your other events use another scope. Both subscriptions can send to the same URL when they have the same signing key.

The Webhook block offers these Calendly event types: `invitee.created`, `invitee.canceled`, `invitee_no_show.created`, `invitee_no_show.deleted`, `routing_form_submission.created`, `event_type.created`, `event_type.updated`, and `event_type.deleted`.

## Save the Signing key

Calendly signs each request with the signing key from the subscription. The same value lets OutWin check that signature.

1. In OutWin, paste the signing key into **Signing key** in the block's settings.
2. Select **Save**.

After you save, the settings show only the last four characters of the key, with **Replace** and **Remove**. Under **Set up**, the second line changes to "The signing key is saved: deliveries are verified."

OutWin saves the key on the block's URL. It is not saved on a connection. A second Webhook block has its own URL and needs its own subscription and key.

With a key saved, OutWin also checks the time in the signature. A request signed more than three minutes before or after the moment it arrives is listed as **Refused**. Inside those three minutes, a saved copy of a signed request that is sent again passes the check and starts another run, because Calendly sends no event id to tell the two apart.

Without a saved key the block still starts runs, and nothing is verified: anyone who has the URL can start the workflow. Publishing then shows a warning that ends "has no signing secret saved, so its deliveries are not verified: anyone who has this URL can start this workflow". The warning does not block publishing.

## Choose which events start a run

Under **Events that start a run**, tick the event types that start a run. With none ticked, every event Calendly sends starts a run. To start runs for a type that is not listed, type it into the box under the list and select **Add**.

An event whose type is not ticked is listed as **Filtered out** and starts no run. To narrow further by a field of the event, add a row under **Only when**. Calendly wraps what happened in a `payload` field, so a field of the booking has a path that starts with `body.payload`. [Webhook settings](https://outwin.ai/docs/reference/triggers-approvals-and-waits/#webhook-settings) lists the comparisons.

## Send a test and check what arrived

1. In Calendly, do something that causes one of the subscribed events, such as booking a meeting on one of your own event types.
2. In OutWin, look under **Recent deliveries** in the block's settings.

**Recent deliveries** lists every event that reached the URL, including while the workflow is a draft. On a draft each event is listed as **Dropped** with "The workflow is not published, so nothing ran." It starts no run and is not run later. The last line under **Set up** changes from "Waiting for the first event…" to, for example, "Received invitee.created. Dropped."

With a key saved, an event listed as **Dropped** on a draft has passed the signature check. A delivery that fails the check is listed as **Refused**.

If you have edit access, select an event to see what the block passed on. The list is kept for seven days, and the data of the newest 20 events is kept.

## Read the event in the next block

Each run receives one Calendly request. Calendly wraps the event: the body holds the event's type and time, and what happened is one level down, at `body.payload`. An HTTP request block or a database block directly after the Webhook block reads it with these expressions. An AI block such as **Think** receives the whole value as its input.

| Expression | What it holds |
| --- | --- |
| `{{input.body}}` | The request as Calendly sent it, with the fields `event`, `created_at`, `created_by`, and `payload`. |
| `{{input.body.payload}}` | What happened: the booking for an `invitee.created` event, for example. Its fields depend on the event type. |
| `{{input.body.created_by}}` | One field of the request. Read any other field the same way. |
| `{{input.event.type}}` | The event's type, such as `invitee.created`. It is the body's `event` field. |
| `{{input.event.id}}` | Empty. Calendly sends no id for an event. |
| `{{input.event.time}}` | The event's time as an ISO 8601 date and time. It is read from the body's `created_at` field. |
| `{{input.delivery.verified}}` | `true` only when the signature was checked and passed. |

A block further along reads the same values through the Webhook block's name, as in `{{steps["Calendly"].body.payload}}` for a block named `Calendly`. [Data and context](https://outwin.ai/docs/reference/data-and-context/) describes what each block passes on.

## Publish and check the runs

[Publish the workflow](https://outwin.ai/docs/run/publish-and-start/). From then on, each event that passes the filter starts a run. On a published workflow the block's settings are read-only, and **Recent deliveries** is in the block's inspector. You can still replace the key there.

| Outcome | What happened |
| --- | --- |
| **Ran** | The event started a run. |
| **Waiting** | 10 runs of the workflow are already active. The event starts a run when one of them ends. An event that waits longer than an hour is listed as **Dropped**. |

The block does not skip duplicates for Calendly, because a request carries no event id. If Calendly delivers the same event twice, it starts two runs.

Runs start in the order events arrive. That is not always the order things happened, so do not build a workflow that relies on `invitee.created` arriving before `invitee.canceled`.

Receiving an event costs no credits, and neither does an event that is filtered out. A run that starts uses credits for the blocks that run in it.

## If nothing runs

Open **Recent deliveries** and read the outcome and the sentence beside the newest event.

| What you see | Cause | Fix |
| --- | --- | --- |
| "Nothing has arrived yet." | No request has reached the URL. | Check that Calendly accepted the request that creates the subscription, that the subscription lists the event you caused and covers the person whose calendar was booked, and that its `url` is the block's current URL. **Rotate token** on a published workflow changes the URL, and the old one stops working. |
| **Dropped** with "The workflow is not published, so nothing ran." | The workflow is a draft. | Publish the workflow. Events that arrived before then are not run later. |
| **Dropped** with "The workflow is paused, so nothing ran." | The workflow is paused. | Resume the workflow. Events that arrived while it was paused are not run later. |
| **Filtered out** with `Events of type "invitee.canceled" are not chosen on this trigger.` | The event's type is not ticked under **Events that start a run**. | Tick the type, or clear every tick so that all events start a run. The settings are read-only on a published workflow. |
| **Refused** with "The signature did not match. Check that the secret saved here is the one the sender shows for this URL." | The saved key is not the `signing_key` the subscription was created with. You chose that key, so "the one the sender shows" in the message means the value you sent. | Select **Replace** and save the key you sent. If you no longer have it, create a new subscription with a new key, save that key, and remove the old subscription. You do not republish the workflow. |
| **Refused** with "The request carried no signature." | A key is saved in OutWin, and the request did not carry Calendly's signature. This happens when the subscription was created without `signing_key`, and when a request is sent by hand to try the URL. | Create the subscription again with `signing_key`, or cause the event in Calendly so that Calendly sends the request. |
| **Refused** with "The request's timestamp is too far from now, so it may be a replay of an old delivery." | The request was signed more than three minutes before or after it arrived, for example because a saved copy of an earlier request was sent again. | Cause a new event in Calendly. |

A delivery listed as **Refused** is answered with status `401` and starts nothing. OutWin keeps none of its data. For every other outcome in the table, Calendly receives a success response and OutWin does not run the event later.
