# Use Orbit Flows with Zapier

> Start a Zap from anything that happens in your satellites, with a webhook or a flow step, check the signature with Code by Zapier and use the event's fields in your actions.

Source: https://docs.bifrostorbit.com/orbit/admins/flows-zapier/

Zapier runs Zaps: a trigger, then actions in other apps. With Orbit Flows and webhooks, the trigger can be anything that happens in your satellites. For example, Northwilds sends every new Presence Orbit review to a Zap that posts it in a shared spreadsheet and alerts the shop manager.

You need an owner or admin role in your organisation, a paid satellite plan (see [Who can use webhooks](https://docs.bifrostorbit.com/orbit/admins/webhooks/)) and a Zapier plan that includes **Webhooks by Zapier**, which is one of Zapier's premium apps.

## Choose how to send

- **A webhook in Orbit**, under **Webhooks**, sends every event you tick, signed. Use it when the Zap should decide what happens.
- **Send to a webhook** in a flow sends only when the flow's conditions are true, after an approval or an AI step if you add one. It is not signed.

[Use Orbit Flows with Make](https://docs.bifrostorbit.com/orbit/admins/flows-make/) compares the two in a table.

## 1. Get an address from Zapier

1. In Zapier, create a Zap and choose the trigger.
2. Choose **Webhooks by Zapier**, then the event **Catch Hook**. To check signatures, choose **Catch Raw Hook** instead; see step 4.
3. Choose **Continue**. Zapier shows an address like `https://hooks.zapier.com/hooks/catch/1840422/reviews/`. Copy it.

## 2. Send events to Zapier

### With a webhook

1. In Orbit, open **Organisations**, choose your organisation, then **Webhooks**, and choose **Add webhook**.
2. Name it, such as Reviews to Zapier, and paste the Zapier address into **Address**.
3. Tick the events, such as `presence.review.received`, and choose **Add webhook**.
4. Copy the **signing secret** Orbit shows once.
5. Choose **⋯** next to the webhook, then **Send a test**.

In Zapier, choose **Test trigger**. The test message from Orbit appears, and its fields can be used in your actions.

### Or from a flow

1. In Orbit, open **Flows**, open a flow and choose **Add a step**, then **Send to a webhook**.
2. Paste the Zapier address and choose **JSON for your own system**.
3. Write a message and choose **Save flow**. Choose **Run now**, or wait for the next event, to send a first message Zapier can test with.

## 3. Use the fields

Zapier lists the fields of the message by name:

- From a webhook in Orbit: **Event** is the event's type, and the details are under **Data**, such as **Data Rating**, **Data Location** and **Data Text** for a review.
- From a flow step: the event is under **Event Data**, your message is **Message**, and an AI step's text is under **Steps**.

Every field each event has is in the [event reference](https://docs.bifrostorbit.com/reference/events/). Add a **Filter by Zapier** step to go on only for some events, such as a rating under 3.

## 4. Check the signature

With **Catch Raw Hook**, Zapier passes on the body as text and the headers, so the signature can be checked:

1. Add an action: **Code by Zapier**, **Run JavaScript**.
2. Under **Input Data**, add `body` (the raw body), `timestamp` (the `X-Orbit-Timestamp` header) and `signature` (the `X-Orbit-Signature` header).
3. Paste this code, with your signing secret:

```js
const crypto = require("crypto");
const secret = "your signing secret";
const expected = crypto.createHmac("sha256", secret).update(`${inputData.timestamp}.${inputData.body}`).digest("hex");
const fresh = Math.abs(Date.now() - Number(inputData.timestamp)) < 5 * 60 * 1000;
if (expected !== inputData.signature || !fresh) throw new Error("Not from Bifröst Orbit");
return JSON.parse(inputData.body);
```

The Zap stops at this step for anything not signed with your secret, and later steps use the fields it returns. Better still, keep the secret in Zapier's storage rather than in the code. Flow steps are not signed, so treat their address like a password.

## 5. Publish the Zap

Choose **Publish**. Zapier answers straight away, so Orbit counts each message as delivered and tries again for up to 24 hours if Zapier can't be reached.
