> ## Documentation Index
> Fetch the complete documentation index at: https://docs.referbro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: Full WhatsApp Referral Loop

> Set up the complete automated WhatsApp referral cycle from purchase to reward

## Overview

This recipe sets up the **full referral loop** — a chain of automated WhatsApp messages that guide both the referrer and their friend through the entire referral journey, from initial share to reward payout.

**The complete loop:**

```mermaid theme={null}
graph TD
    A["🛍️ Customer Places Order"] --> B["📱 Order Confirmation<br/><i>WhatsApp: 'Share and earn!'</i>"]
    B --> C["👋 Friend Clicks Referral Link"]
    C --> D["🎁 Friend Sees Discount Popup<br/><i>On your storefront</i>"]
    D --> E["✅ Friend Makes a Purchase"]
    E --> F["🔔 Post-Referral Follow-up<br/><i>WhatsApp to referrer: 'Your friend bought!'</i>"]
    F --> G["📦 Friend's Order Delivered"]
    G --> H["🎉 Reward Notification<br/><i>WhatsApp to referrer: 'You earned ₹150!'</i>"]
    H --> I["🔄 Referrer Shares Again"]
    I --> C

    style A fill:#0D9488,color:#fff
    style E fill:#0D9488,color:#fff
    style H fill:#0D9488,color:#fff
```

**Time to complete:** \~20 minutes

***

## Prerequisites

Before starting, ensure you have:

* An **active campaign** (see [Campaign Management](/docs/features/campaigns))
* A **WhatsApp provider connected** (see [Provider Setup](/docs/features/whatsapp/providers))
* **4 approved WhatsApp templates** on your provider's platform (you'll create these below)

***

## Steps

<Steps>
  <Step title="Prepare Your WhatsApp Templates">
    Create these 4 templates on your provider's platform (e.g., Pragma, Meta). All should be in the **Marketing** category.

    <CodeGroup>
      ```text Order Confirmation theme={null}
      Template Name: referbro_post_purchase

      Body:
      Hey {{1}}! 🎉 Thanks for your order.

      Share your unique link with friends — they get ₹150 OFF, and you earn ₹150 cashback!

      👇 Tap below to share using this link: {{2}}
      Start sharing now!

      Button: [Shop Now] → URL with {{1}} parameter
      ```

      ```text Post-Referral Follow-up theme={null}
      Template Name: referbro_post_referral

      Body:
      Great news, {{1}}! 🙌

      Your friend just used your referral link and placed an order. Your reward will be credited after the return window.

      Keep sharing to earn more! 👇 Use this link: {{2}}
      More shares, more rewards.

      Button: [Share Again] → URL with {{1}} parameter
      ```

      ```text Reward Notification theme={null}
      Template Name: referbro_reward

      Body:
      🎉 Congratulations, {{1}}!

      You've earned ₹150 cashback from a successful referral. Your reward has been credited.

      Refer more friends to keep earning! 👇 Your link: {{2}}
      Keep it going!

      Button: [Refer More] → URL with {{1}} parameter
      ```

      ```text Nudge Reminder theme={null}
      Template Name: referbro_nudge

      Body:
      Hey {{1}}! 👋

      You haven't shared your referral link in a while. Your friends are missing out on ₹150 OFF!

      Share now and earn ₹150 for every friend who buys 👇 Use this link: {{2}}
      Start with one share today.

      Button: [Share Now] → URL with {{1}} parameter
      ```
    </CodeGroup>

    Submit all 4 templates for Meta approval. Approval usually takes minutes to a few hours.

    <Warning>
      Wait for **all templates to be approved** before proceeding. Unapproved templates will cause message delivery failures.
    </Warning>

    <Tip>
      Keep templates Meta-compliant: do not start or end with variables, use sequential placeholders (`{{1}}`, `{{2}}`, ...), avoid placing variables directly next to each other, keep body text under 1,024 characters, header text under 60 characters, and each button label under 25 characters.
    </Tip>

    <Tip>
      You can use ChatGPT (or any AI agent) to generate the Referbro mapping JSON by sharing your template text plus the template-parameter documentation. Always review once before saving.
    </Tip>
  </Step>

  <Step title="Map Templates in Referbro">
    Go to **Apps → Referbro → WhatsApp Settings** and configure each template slot:

    **Order Confirmation**:

    ```json theme={null}
    {
      "body.1": "{{FIRST_NAME}}",
      "body.2": "{{REFERRAL_LINK}}&source=order",
      "languageCode": "en",
      "button.url.0.1": "{{REFERRAL_CODE}}&source=order_cta"
    }
    ```

    **Post-Referral Follow-up**:

    ```json theme={null}
    {
      "body.1": "{{FIRST_NAME}}",
      "body.2": "{{REFERRAL_LINK}}&source=post_referral",
      "languageCode": "en",
      "button.url.0.1": "{{REFERRAL_CODE}}&source=post_referral_cta"
    }
    ```

    **Reward Notification**:

    ```json theme={null}
    {
      "body.1": "{{FIRST_NAME}}",
      "body.2": "{{REFERRAL_LINK}}&source=reward",
      "languageCode": "en",
      "button.url.0.1": "{{REFERRAL_CODE}}&source=reward_cta"
    }
    ```

    **Nudge Reminder**:

    ```json theme={null}
    {
      "body.1": "{{FIRST_NAME}}",
      "body.2": "{{REFERRAL_LINK}}&source=nudge",
      "languageCode": "en",
      "button.url.0.1": "{{REFERRAL_CODE}}&source=nudge_cta"
    }
    ```

    Toggle each template to **Enabled**.
  </Step>

  <Step title="Enable the Storefront Widgets">
    1. Go to **Shopify Admin → Online Store → Themes → Customize**.
    2. Enable both **App Embeds**:
       * **Refer & Earn** — the floating share button
       * **Referral Received** — the discount popup for referred friends
    3. Go to **Settings → Checkout → Customize** and add the **Referbro Widget** to the **Thank You** page.
    4. Click **Save** in both editors.
  </Step>

  <Step title="Test the Complete Loop">
    Walk through the full referral cycle:

    1. **Place a test order** → Check that you receive the Order Confirmation message on WhatsApp.
    2. **Click the referral link** from the message → Verify the store loads and the Referral Received popup appears with the discount.
    3. **Place a second order** using the referral discount → Check that the original referrer receives the Post-Referral Follow-up message on WhatsApp.
    4. **Verify in Analytics** → Go to **Apps → Referbro → Analytics** and confirm events: `LINK_GENERATED`, `WHATSAPP_SENT`, `LINK_CLICKED`, `ORDER_PLACED`.

    <Tip>
      Use the **Send Test Message** button in WhatsApp Settings to quickly test individual templates without placing orders.
    </Tip>
  </Step>
</Steps>

***

## Best Practices

* **Start with 2 templates**, not 4 — Begin with **Order Confirmation** and **Referral Invitation**. Add the others once these are working.
* **Track UTM sources** — The `&source=` parameters in the template configs let you see in Analytics which touchpoint drives the most referrals.
* **Use the Nudge feature weekly** — Go to **Apps → Referbro → Nudge Users** and send reminders to dormant referrers every 7–14 days.
* **Monitor delivery rates** — If WhatsApp delivery rates drop, check that your templates haven't been paused by Meta (common if too many users report them as spam).

## Related Pages

* [WhatsApp Integration](/docs/features/whatsapp/overview) — Template parameters reference
* [WhatsApp Touchpoints](/docs/features/whatsapp/touchpoints) — Full list of 8 trigger points
* [Provider Setup](/docs/features/whatsapp/providers) — Getting API credentials
* [Nudges](/docs/features/nudges) — Manual re-engagement messaging
