# Send invites automatically from Shopify

Ask each Shopify customer for a testimonial once their order is paid or fulfilled, with a Smart Invites webhook your store signs.

Connect your Shopify store so that each paid order adds its customer to your invite emails. You create a Shopify webhook in ReTestimonial, then add its URL in your Shopify admin. Smart Invites are on Premium and Business, and you need to own the workspace or be an **Admin** on the project.

This page covers what's particular to Shopify. Every setting of a webhook is explained in [Send invites automatically with a webhook](/help/collect/send-invites-automatically-with-a-webhook).

1. **Create a Shopify webhook in ReTestimonial**

   In your project, open **Invites** under **Collect**, go to the **Webhooks** tab and click **New webhook**. Under **Where do your customers buy?**, choose **Shopify**.

   The field paths come filled in for a Shopify order, with an extra field named `product` that reads what the customer bought (see [What we read from a Shopify order](#what-we-read-from-a-shopify-order)), and **Only invite when (optional)** stays empty. Click **Continue**, choose the **Form**, the **Email sequence** and the timing, then click **Create webhook**.

2. **Add the webhook in Shopify**

   Click **Copy** next to **Your webhook URL**. Then, in your Shopify admin:

   1. Go to **Settings** > **Notifications**, click **Webhooks**, then **Create webhook**.
   2. For **Event**, choose **Order payment**, or **Order fulfillment** to ask once the order ships.
   3. For **Format**, choose **JSON**.
   4. Paste the URL into **URL** and click **Save**.

   Shopify's own steps are in [Creating webhooks](https://help.shopify.com/en/manual/fulfillment/setup/notifications/webhooks) in the Shopify Help Center.

3. **Paste your store's signing key**

   On the same **Webhooks** page, Shopify shows the key your webhooks are signed with ("Your webhooks are signed with …"), a string of letters and numbers unique to your store. Copy it, paste it into **Shopify webhook signing secret (recommended)** in ReTestimonial and click **Save**.

   The field then reads **Signature verification is on — unsigned events are rejected.** From now on, only events signed by your store are accepted.

4. **Wait for the first order**

   The page shows **Listening for the first event…** until Shopify sends an order, then **Event received — it works**, or why the event was skipped or failed. You can leave the page; the webhook is already live.

## Shopify's test doesn't use an invite

Shopify's **Send test notification**, in the webhook's row on its **Webhooks** page, sends a sample order to the URL. ReTestimonial recognizes it as a test: the event shows up as skipped, with the reason "A test event from the platform, so nobody was invited and no invite was used". Orders placed with Shopify's test payment gateway are skipped the same way. That confirms the connection without emailing anyone.

To check how the webhook reads an order, use its **Test** tab. It runs a sample Shopify order, or an order you paste, through the webhook; nothing is saved and no email is sent. See [Test a Smart Invites webhook](/help/collect/test-a-smart-invites-webhook).

## Order payment or Order fulfillment

- **Order payment** arrives when an order is paid, usually right after checkout and before the customer has the product. To give it time to arrive, set **Wait before the first email** on the webhook.
- **Order fulfillment** arrives once the order ships.

Both events carry the same order, so the paths work for either. ReTestimonial doesn't check which event Shopify sends: every order that reaches the URL invites its customer. Choose the event carefully. **Order creation**, for example, could invite customers before they've paid.

Shopify can't change a webhook's event after it's created. To switch, create a new webhook in Shopify with the same URL and delete the old one.

## Sales in your shop (Shopify POS)

To ask the customers who buy in person, pick the **Shopify POS** tile instead of **Shopify**. It's the same **Order payment** webhook in Shopify, with **Only invite when (optional)** set to `source_name` **equals** `pos`, so only sales made with Shopify POS invite. It starts with the same `product` extra field. **Wait before the first email** starts at one day, so the ask arrives the day after the visit; change it to suit your shop.

A sale has an email address only when you add a customer with one to it at checkout. A sale without one shows as **Failed** with "No email was found at the mapped path", and nobody is invited. To ask everyone, including customers you don't add at the till, put a [counter card](/help/collect/share-your-form#print-a-counter-card) by the register too.

## What we read from a Shopify order

| Field                                  | Default path              | What it holds                                                                                           |
| -------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------- |
| **Email path**                         | `email`                   | The order's email address                                                                               |
| **Name path**                          | `customer.first_name`     | The customer's first name                                                                               |
| **Company path**                       | `billing_address.company` | The company on the billing address                                                                      |
| **Extra fields (optional)**: `product` | `line_items[0].title`     | The title of the order's first product, without its variant: "Linen Apron", not "Linen Apron - Oat / M" |

The email comes from the order itself, not from its customer record: point-of-sale and some guest orders have no customer record. Those customers are still invited, just without a name.

There's no default **Only invite when (optional)** filter on the **Shopify** tile. Shopify names the event in the request's headers, not in the order, so you choose it in Shopify instead. The **Shopify POS** tile filters on the order's `source_name`.

## Name the product in your emails

The `product` extra field lets an email say what the customer bought. In your email sequence's subject or body, write `{meta:product}`, or `{meta:product|order}` to show "order" when an order has no product name. `How's your {meta:product|order}?` then reads "How's your Linen Apron?", and "How's your order?" for an order without one. The project's default template doesn't use the tag: add it to a template of your own (see [Customize your invite emails](/help/collect/customize-invite-emails)). How the fallback works: [A fallback for a missing value](/help/collect/invite-email-merge-tags#a-fallback-for-a-missing-value).

- **Only the first item is read.** For an order of several products, the email names the first one.
- **To include the variant,** such as "Linen Apron - Oat / M", change the field's **Field path** to `line_items[0].name`.
- **To leave it out,** click the X beside the field. The webhook works the same without it.
- **On your form,** a [custom field](/help/manage/custom-fields) named "Product", switched on for its **About You** or **About Company** page, comes filled in with the product's name.
- **Per product:** on Business, a routing rule with **Source** set to **Metadata Key** and the field `product` can send each product's buyers to their own form.

A webhook you created before this field was added keeps the fields it has. To add it, open the webhook's **Settings** and, under **Extra fields (optional)**, click **Add a field**: **Name** `product`, **Field path** `line_items[0].title`.

## When a Shopify order isn't invited

The webhook's **Activity** tab shows each event as **Invited**, **Skipped** or **Failed**, with the reason.

| Reason shown                                                                                                               | Why, and what to do                                                                                                                                                                           |
| -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Failed**: "No email was found at the mapped path"                                                                        | The order has no email address, so there's nobody to invite.                                                                                                                                  |
| **Failed**: "The platform sent a body that is neither JSON nor form data (XML isn't read). Set the platform to send JSON." | The Shopify webhook's **Format** is **XML**. Edit the webhook in Shopify and set it to **JSON**.                                                                                              |
| **Failed**: "The signature didn't match"                                                                                   | The key you saved isn't your store's, and every order from Shopify is refused until it is. On the **Setup** tab, click **Replace secret** and paste the key from Shopify's **Webhooks** page. |
| **Skipped**: "Customer was already invited within the cooldown window"                                                     | A repeat customer who was invited recently. Nothing to do.                                                                                                                                    |

If Shopify delivers the same event twice, for example when it retries a delivery, the customer is invited once.

## Next steps

- [Customize invite emails](/help/collect/customize-invite-emails)
- [Track invite campaigns](/help/collect/track-invite-campaigns)
- [Manage the do-not-email list](/help/collect/manage-the-do-not-email-list)
- [Invite emails not sending](/help/troubleshooting/invite-emails-not-sending)
