Templates

Welcome Coupon Campaign

A new customer signs up. The workflow creates a unique coupon code, sends it by email, and checks redemption before each follow-up. Unused codes get a day-three reminder and a final expiry message. Redeemed codes stop further emails.

10 minutes setupUpdated 2026-05-21

What it does

This template sends up to three emails over five days, depending on whether the customer redeems their coupon. If they redeem on day one, follow-ups stop. If they do not redeem, they get a reminder on day three and a final message before expiry.

Codes are generated in JavaScript and stored in MongoDB. Redemption is checked from that collection, so you keep the data and avoid a separate voucher API.

How it runs

A new customer hits the trigger. A script generates a unique code in the format WELCOME-<prefix>-<random>, sets a 15% discount, and stamps an expiry seven days out. That voucher is saved to MongoDB with redeemed: false, then Gmail sends the welcome email with the code.

The workflow waits three days and checks MongoDB. If redeemed is true, it exits. If not, it sends a reminder, waits two more days, and checks again. If the code is still unused, it sends a final expiry email. If redemption happens at any point, the workflow exits quietly. Your checkout must set redeemed to true when the code is used.

The steps

  • JavaScript (map_input): Pulls email, name, and a source ID from the trigger payload.
  • JavaScript (generate_voucher): Builds the unique code, sets the discount label, and calculates the 7-day expiry.
  • MongoDB (store_voucher): Inserts the voucher document. This is the source of truth for redemption status.
  • Gmail (gmail_send_welcome): Welcome email with the code, discount, and expiry date.
  • Wait (wait_1): 3 days.
  • MongoDB (check_redemption): Looks up the voucher to see if it has been redeemed.
  • Switch (check_redeemed_branch): Redeemed exits. Not redeemed continues to the reminder sequence.
  • Gmail (gmail_send_reminder): Day 3 reminder with the same code.
  • Wait (wait_2): 2 more days.
  • MongoDB (check_redemption_final): Second redemption check.
  • Switch (final_expiry_branch): Redeemed exits. Still unused sends the final expiry email.
  • Gmail (gmail_send_expiry): Last-chance email before the code expires.

Design notes

Redemption is checked before each reminder, not after. If a customer redeems on day two, they do not receive the day-three reminder. That avoids sending a discount reminder after the code is already used.

The voucher code is generated locally and stored in MongoDB, not pulled from a voucher service. Your checkout should set redeemed: true when the code is used, usually a small update in your order flow. Once that is wired, the workflow runs without external voucher dependencies.

Setup

  1. Connect your MongoDB and Gmail integrations.
  2. Create a vouchers collection (no schema required; the workflow writes the document shape).
  3. Replace the from address in the three Gmail steps with your verified sender.
  4. Set the shop_url workflow variable to your storefront link.
  5. Update vouchers.redeemed to true in checkout when a code is used, filtering by the code field.
  6. Trigger with a payload containing subscriberEmail, subscriberName, and subscriberSourceId.

When to use it

  • E-commerce welcome flows where you want unique-per-customer codes instead of a shared WELCOME15.
  • You want to stop follow-ups after a customer has already purchased.
  • You prefer not to pay a separate voucher platform per code.

Adapt this template in Unmeshed

Start from the sequence above, then connect your APIs, approvals, decision logic, and notifications as durable workflow steps.