Blog/Automation

How to Send WhatsApp Discount Codes to Shopify Customers with Rapiwa and n8n

Automatically send personalized WhatsApp discount codes to Shopify customers using Rapiwa API and n8n. 74 installs. Recover abandoned carts and boost repeat purchases automatically.

by Julfiker
How to Send WhatsApp Discount Codes to Shopify Customers with Rapiwa and n8n

This n8n workflow automatically sends personalized Shopify discount codes to customers via WhatsApp using Rapiwa API. Trigger it after a first purchase, abandoned cart, or re-engagement campaign to bring customers back. Rapiwa charges $5/month flat with no per-message fees. Over 74 developers have installed this template from the n8n marketplace.

What This Workflow Does

When triggered (new order, abandoned cart, or scheduled campaign):

  1. n8n fetches or creates a Shopify discount code for the customer
  2. Builds a personalized WhatsApp message with the code and expiry
  3. Sends the message via Rapiwa API to the customer's WhatsApp number

Use cases:

  • Post-purchase: "Thank you" discount for the next order
  • Win-back: Re-engage customers who haven't ordered in 30 days
  • VIP rewards: Send exclusive codes to high-value customers
  • Abandoned cart: Offer a discount to complete a pending order

Ready-made template: Import with one click: Automatically send WhatsApp discount codes to Shopify customers using Rapiwa →(74 installs)

Prerequisites

  • Rapiwa accountStart free 3-day trial →
  • n8n — Cloud free tier or self-hosted
  • Shopify store — Admin API access token
  • Customer phone numbers stored in Shopify customer profiles

Step 1: Import the n8n Template

  1. Go to n8n.io/workflows/9560
  2. Click Use this workflow
  3. The workflow nodes:
    • Schedule Trigger (or Shopify Trigger) → fires on the desired event
    • Shopify node → fetches customer data or creates a discount code
    • Set node → builds the personalized message
    • HTTP Request (Rapiwa) → sends the WhatsApp message

Step 2: Configure Shopify API Credentials

  1. In Shopify Admin → Settings → Apps → Develop apps
  2. Create an app: n8n WhatsApp Discounts
  3. Admin API scopes: write_discounts, read_customers, read_orders
  4. Copy the Access Token to n8n Shopify credentials

Step 3: Create a Shopify Discount Code via API

The workflow uses the Shopify Price Rules API to create a unique code for each customer:

# Step 1: Create a price rule
curl -X POST https://yourstore.myshopify.com/admin/api/2024-04/price_rules.json \
  -H "X-Shopify-Access-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "price_rule": {
      "title": "WELCOME-SARAH-20",
      "target_type": "line_item",
      "target_selection": "all",
      "allocation_method": "across",
      "value_type": "percentage",
      "value": "-20.0",
      "customer_selection": "prerequisite",
      "prerequisite_customer_ids": [67890],
      "usage_limit": 1,
      "starts_at": "2026-06-19T00:00:00Z",
      "ends_at": "2026-06-26T23:59:59Z"
    }
  }'
# Step 2: Create the discount code under that price rule
curl -X POST https://yourstore.myshopify.com/admin/api/2024-04/price_rules/PRICE_RULE_ID/discount_codes.json \
  -H "X-Shopify-Access-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "discount_code": {
      "code": "WELCOME-SARAH-20"
    }
  }'

In n8n, these two HTTP Request nodes are already pre-configured in the template.

Step 4: Configure the Rapiwa Send Node

Find the HTTP Request node "Send WhatsApp Discount":

  • Method: POST
  • URL: https://app.rapiwa.com/send-message
  • Authorization: Bearer YOUR_API_KEY
  • Body:
{
  "number": "={{ $json.customer_phone }}",
  "message": "={{ $json.discount_message }}"
}

Working cURL test:

curl -X POST https://app.rapiwa.com/send-message \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "number": "8801234567890",
    "message": "Hi Sarah! 🎉 Here is your exclusive 20% discount:\n\n🎟️ *WELCOME-SARAH-20*\n\n✅ 20% off everything\n✅ Valid until June 26, 2026\n✅ Just for you\n\nShop now: https://yourstore.com?discount=WELCOME-SARAH-20\n\n— The Team at YourStore"
  }'

Expected response:

{
  "status": "success",
  "messageId": "msg_shopify_discount123",
  "timestamp": "2026-06-19T10:30:00Z"
}

Step 5: Segment Your Customer List

Don't send discount codes to all customers indiscriminately. Segment in n8n:

SegmentTriggerDiscount %Message angle
First-time buyersOrder count = 1, order completed10%"Thank you for your first order"
Lapsed customersNo order in 30 days20%"We miss you — here's 20% off"
High-value customersOrder total > $20015%"VIP exclusive discount"
Abandoned cartCart abandoned 1 hour ago10%"Still thinking about it?"

In n8n, use an IF or Switch node to route customers to different message templates based on these criteria.

Step 6: Track Redemption

Add a post-send step to log discount codes in a Google Sheet:

ColumnValue
customer_id67890
phone8801234567890
discount_codeWELCOME-SARAH-20
sent_at2026-06-19T10:30:00Z
redeemedFALSE

Set up a Shopify webhook for discounts/applied to update the redeemed column when the code is used.

Real-World Results

  • 74 Shopify stores already use this exact workflow
  • WhatsApp discount codes have 3–5x higher redemption vs email coupon campaigns
  • Abandoned cart WhatsApp messages (sent within 1 hour) recover 15–25% of abandoned orders
  • Win-back campaigns with 20% off re-engage 12–18% of lapsed customers

Common Errors and Fixes

  • 403 on Shopify discount creation: Ensure your API token has write_discounts scope. Recreate the custom app with this scope enabled.
  • Customer phone not available: Shopify doesn't always have customer phones. Check customer.phone and order.billing_address.phone — use whichever is populated.
  • Discount code already exists: Add a timestamp or random suffix to make codes unique: DISC-{{ Date.now() }}
  • 401 from Rapiwa: Regenerate API key in Rapiwa Dashboard → API Keys

FAQ

Can I send the same discount code to multiple customers? For bulk campaigns, create a single price rule with a high usage limit and send the same code to all customers. For personalized campaigns, generate a unique code per customer (as this template does).

How do I prevent customers from sharing their discount code? Set usage_limit: 1 and customer_selection: prerequisite with the specific customer ID — the code only works for that customer and can only be used once.

Does Rapiwa charge per discount code message sent? No. Rapiwa charges $5/month flat with no per-message fees.

Can I send discount codes to customers who've never bought on Shopify? You can send WhatsApp messages to any phone number — the Shopify customer account isn't required for the WhatsApp delivery. However, the discount code creation does require a Shopify customer ID.

What WhatsApp number does the message come from? The message comes from your Rapiwa-connected WhatsApp number. Customers see your number (or saved contact name) as the sender.