# Zapier

> Confirm customers' numbers from any Zapier workflow, for example Shopify cash-on-delivery orders, with the OTP.ps app's triggers and actions.

> **Status: built and tested, not yet in Zapier's app directory.** OTP.ps publishes it from its Zapier developer account; until then, use the [no-app route](#without-the-app) below.

## What the app does

| | |
|---|---|
| **Trigger: Link Confirmed** (instant) | A customer confirmed a [verification link](/docs/verification-links). Gives the link, including your `reference` |
| **Trigger: Link Expired** (instant) | A link wasn't confirmed in time |
| **Action: Create Verification Link** | Texts the customer a link to confirm (or gives you one to share) |
| **Action: Send Verification Code** / **Check Verification Code** | The code flow, for Zaps that collect the code themselves (a form, a chat) |
| **Search: Find Verification Link** | The latest link with your reference |

Connecting asks for an API key; start with a test key (`otp_test_…`), which sends nothing. The triggers register their own [webhook](/docs/webhooks) with OTP.ps and remove it when the Zap is turned off.

## Cash-on-delivery orders from Shopify

**Zap 1**, when an order comes in:

1. Trigger: **Shopify → New Order**. Filter: payment gateway is cash on delivery.
2. Action: **OTP.ps → Create Verification Link**: Mobile Number = the order's phone, What Is Confirmed = Order, Your Reference = the order name (e.g. `#1042`), How = Text the link.
3. Action: **Shopify → Add tag to order**: `awaiting-phone-confirmation`.

**Zap 2**, when the customer confirms:

1. Trigger: **OTP.ps → Link Confirmed**.
2. Action: **Shopify → Find Order** by name = Your Reference, then **Update order**: tag `phone-confirmed`.

Add a third Zap on **Link Expired** to notify your team.

## Without the app

**Webhooks by Zapier** (a paid Zapier plan) does the same with plain requests:

- Create the link with **Webhooks by Zapier → Custom Request**, `POST https://otp.ps/api/v1/verify/links` with the header `Authorization: Bearer <key>` and the JSON body from [Verification links](/docs/verification-links).
- Receive confirmations with **Webhooks by Zapier → Catch Hook**, and add its address on the OTP.ps dashboard (Webhooks, event `link.approved`).

## How it was tested

The app runs with Zapier's own local test tool against the OTP.ps API:
- the connection test, and a wrong key being refused;
- creating, finding and checking;
- the instant trigger subscribing, receiving a confirmed link and unsubscribing.

It also passes the same validation Zapier's publishing tool runs.
