Blog/Guides

Event-Based Email Automation: A Practical Guide With Code

How event-based email automation works, where events come from, what a real event payload looks like, and 12 event-triggered flows with timing for ecommerce and SaaS.

KS

Event-based email automation sends an email because someone did something, like starting a trial, abandoning a checkout or failing a payment, instead of because a date on a calendar arrived. Your app or store reports the action as an event, the email platform matches it to an automation, and the flow runs its waits, conditions and emails for that one person. In Audienceful, events arrive from native Stripe, Shopify and Clerk connections or from one API call, and the same automation builder handles all of them.

We make Audienceful, so the setup steps use it. The concepts, the flow table and the naming advice apply to any platform that accepts custom events.

What event-based email automation is

Every event-triggered flow has the same five parts.

Part What it means Example
Event A record that something happened, with a name, a person and properties trial_started for jane@acme.com, plan pro
Trigger The automation that listens for that event name "When trial_started is received"
Conditions Checks on the person or the event before or between steps Plan is pro, has not activated yet
Actions Emails, waits, field updates, tags Wait 1 day, send "Set up your first project"
Exit The rule that takes the person out of the flow Leaves when subscription_activated arrives

Read it as a straight line. Event comes in, trigger matches, conditions filter, actions run, exit rule stops the flow when the goal is met. Most broken automations are missing the last part, which is how a customer who already paid ends up getting "Your trial ends tomorrow."

Event-based vs time-based email

Time-based email runs on a schedule. The Tuesday newsletter, a monthly digest and a Black Friday campaign all go to a segment at a time you choose. Event-based email runs per person, at the moment their behavior makes the message relevant.

Event-based Time-based
What starts it A person's action (or a missed action) A date and time you set
Who gets it One person, when they qualify A segment, all at once
Timing Relative to the event: 1 hour after, 3 days after Absolute: 9am Tuesday
Typical emails Welcome, cart recovery, dunning, trial ending, win-back Newsletters, launches, sales
Data needed Events with properties from your app, store or billing Contact fields and segments
Maintenance Built once, runs until you change it Written each time

You need both. Event-based flows earn the most per email because they arrive when the person is paying attention to the thing the email is about. Campaigns keep the rest of the list warm. For a store, our guide to Shopify email flows shows how the two fit together.

Where events come from

There are five common sources. Use the native connection where one exists, because it saves you writing and maintaining webhook code.

  1. Your ecommerce platform. Shopify sends orders, checkouts and customers. With the Audienceful storefront pixel, product views and add-to-cart activity come through too, which is what powers browse abandonment. See the Shopify integration.
  2. Your billing system. Stripe knows when a trial starts, when it is about to end, when a payment fails and when a subscription is cancelled. Audienceful's Stripe automations trigger on trial started, trial ending soon, subscription activated, paused, resumed, past due, scheduled to cancel and cancelled, payment succeeded and failed, refunds and new customers. Our Stripe email automation post covers those flows in depth.
  3. Your auth provider. A Clerk signup is the cleanest welcome trigger for a SaaS product. See Connect Clerk to Audienceful.
  4. Your own app, through the API. Anything only your product knows: created a first project, invited a teammate, hit a plan limit, went quiet for 14 days. This is where custom events come in.
  5. Zapier. For tools without a native connection, a Zap can turn a form fill, a CRM stage change or a calendar booking into an event. See Connect Audienceful to Zapier.

If you already handle Stripe webhooks in your own backend, Stripe webhook emails shows how to pass those on as events without rebuilding the logic.

How to send a custom event

In Audienceful, you first create the event, either on the Events settings page or inside the automation builder, and define the properties it carries. Then you set an automation's trigger to "Custom" and pick that event. The full walkthrough is in custom automation events.

Sending the event is one HTTP request to the trigger event endpoint. This is the request from our API reference:

Bash
curl --request POST 'https://api.audienceful.com/v2/automations/event' \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <your-api-key>' \
  --data-raw '{
    "email": "jane@acme.com",
    "event": "hit_plan_limit",
    "event_properties": {
      "limit_name": "projects",
      "limit_value": 3,
      "upgrade_url": "https://app.example.com/billing"
    },
    "add_person": true,
    "fields": {
      "plan": "starter"
    }
  }'

What each part does:

  • email and event are required. The event name must match one defined in the workspace, case-insensitively. An unknown name returns a 404, which is useful: a typo fails loudly instead of silently dropping the email.
  • event_properties are values for this one occurrence. They fill matching data variables in every email of the automation, so the email can say "You've used all 3 projects" and link to the right billing page.
  • fields update the contact record itself. Use them for facts that stay true after the flow ends, like the current plan.
  • add_person creates the contact if they are new. It defaults to true.

The API processes the event asynchronously and returns an operation_id straight away. Call it from your server, never from the browser, because the request carries your API key. The key needs the events:write scope.

Naming conventions that save you later

Event names outlive the people who chose them. A few rules keep them readable a year from now.

  • Use past-tense verbs in snake_case. trial_started, project_created, invoice_paid. The name says what already happened.
  • One name per action, not per variation. Send plan_upgraded with a to_plan property rather than upgraded_to_pro and upgraded_to_team. Conditions can branch on the property.
  • Keep properties flat and typed. Strings, numbers and booleans are easiest to branch on and to drop into an email. Send amount: 49 rather than "$49.00".
  • Put identity in fields, context in properties. The plan someone is on is a field. The project that just hit its limit is a property.
  • Write the list down. A short table of event names, what fires them and their properties stops two engineers from shipping signup and signed_up.

When the action is "nothing happened"

Inactivity is the event teams forget. Email platforms can't see a login that never occurred, so you report it. Two common patterns work:

  1. A nightly job in your app finds users with no key action in 14 days and sends went_inactive for each one.
  2. You update a last_active_at field on every session and build a segment on it, then trigger the flow when someone enters the segment.

The first is easier to reason about. The second keeps the logic in the email platform, where a marketer can change "14 days" without a deploy. Our post on reactivation emails for inactive users has sequences for each kind of inactivity.

12 event-triggered flows, with timing

These are the flows worth building first. Timings are starting points; change them once you have your own data.

# Flow Trigger event Timing Exit when
1 Browse abandonment Viewed product, no cart 1 to 4 hours after the view, one follow-up a day later Added to cart or ordered
2 Cart abandonment Added to cart, no checkout 1 hour, then 24 hours Started checkout or ordered
3 Checkout abandonment Started checkout, no order 1 hour, 24 hours, optional third at 48 to 72 hours Order placed
4 Post-purchase Order placed Thank-you at once, how-to at delivery, review request 7 to 14 days after delivery Refund or next order resets
5 Replenishment Order placed for a consumable A few days before the product runs out Reorder placed
6 Welcome or onboarding Signed up (Clerk, form or API) Immediately, then day 1, 3, 5 Activated
7 Activation rescue Signed up, no key action Day 2 and day 5 after signup Key action event
8 Plan limit Hit plan limit Immediately, one reminder 3 days later Plan upgraded
9 Trial ending Stripe trial ending soon 3 days before trial end, then on the last day Subscription activated
10 Failed payment (dunning) Stripe payment failed Same day, day 3, day 7, final notice before cancellation Payment succeeded
11 Inactive user Went inactive (14 days) Day 0, day 7, day 21 Any key action
12 Cancellation and win-back Stripe subscription cancelled Same day, 30 days, 60 to 90 days Subscription reactivated

Flows 1 to 5 are ecommerce. Audienceful has templates for browse abandonment, add-to-cart, abandoned checkout, post-purchase and replenishment, all triggered by native Shopify data. See Shopify automations.

Flows 6 to 12 are SaaS. The Stripe ones have ready templates too: trial onboarding, trial ending, dunning and subscription win-back. See Stripe automations. Activation rescue, plan limit and inactivity need custom events from your app, because only your product knows those things happened. The SaaS cancellation email post has copy for flow 12.

Branching, exit conditions and frequency caps

A trigger decides who enters. Everything after that decides whether the flow helps or annoys.

Branch on event properties and fields

A conditional step reads a field or an event property and sends people down different paths. Three branches pay for themselves in most programs:

  • Plan or value. A cart_value above a threshold gets a free-shipping reminder; below it gets a product recommendation. A pro trial gets the team-features email; a starter trial doesn't.
  • Progress. If the person already did the next step (a project_created field is true), skip the email that tells them how.
  • Source. Signups from a webinar get a different first email from signups from a pricing page.

Exit on the goal, not the last email

Every flow should end when its goal happens, even mid-sequence. The dunning flow stops on payment succeeded. Trial ending stops on subscription activated. Checkout recovery stops on the order. In Audienceful, add a condition check before each email or end the flow on the goal event; whichever you choose, test it with a real conversion in the middle of the sequence.

Cap the total across flows

Each flow can be sensible on its own and still pile up. Someone who signs up, browses, abandons a cart and gets a newsletter could receive five emails in two days. Three habits keep that under control:

  1. Rank your flows. Money flows (dunning, checkout) beat nudges (browse, activation). If someone is in a higher flow, hold the lower one.
  2. Add a quiet window. Skip a nudge if the person received any email in the last 24 hours.
  3. Exclude active flow members from campaigns. A trial user in onboarding doesn't need this week's promotional broadcast too.

Over-mailing shows up as rising unsubscribes and spam complaints. Our email deliverability checklist covers the thresholds mailbox providers watch.

Testing and QA before you switch a flow on

Event flows fail quietly. A misspelled event name or a property that never arrives produces no error your customer sees, just an email that never sends or one with an empty gap where the plan name should be.

  1. Send a test event for yourself. Use your own email with realistic properties. Check the email arrives with every variable filled.
  2. Check the event log. Audienceful stores every event it receives with the request body on the Events settings page, and the event explorer shows which contacts fired what. If an event isn't in the log at all, the name doesn't match.
  3. Walk each branch. Send one test event per branch value: one pro, one starter, one cart over the threshold, one under.
  4. Test the exit. Fire the trigger, then fire the goal event before the second email. Confirm the second email doesn't go.
  5. Test a repeat. Send the trigger twice for the same person. Decide whether they should enter twice, and make sure the platform does what you decided.
  6. Watch the first week. Look at entries, exits and sends per step in automation analytics. A step with entries and no sends usually means a condition is wrong.

Tools that support event-based email automation

Most platforms can trigger on events now. The differences are in how events get in, how deep the branching goes and what the platform already knows about your customers without code.

Tool How custom events get in Native ecommerce and billing events Best fit
Audienceful Trigger event API, Zapier, webhooks Shopify (orders, checkouts, product views, cart), Stripe billing lifecycle, Clerk signups SaaS and ecommerce teams that want native data plus custom events in one builder
Customer.io Track API events and CDP sources Through integrations and data pipelines Product-led SaaS with an engineering team sending rich behavioral data
Klaviyo Create Event API Deep Shopify data; Stripe through its integration Shopify stores with heavy catalog and order data
Loops Send event endpoint with eventName and eventProperties Through integrations Small SaaS teams that want a simple event API
Moosend Website tracking and automation triggers described on its event-based automation guide Ecommerce integrations Budget-conscious senders with mostly ecommerce triggers

Where Audienceful stands out is the amount you get without writing code. Stripe trial, payment and subscription events, Shopify orders, checkouts and product views, and Clerk signups all arrive natively, with revenue attribution tying each flow back to orders and payments. Custom events cover what's left. The AI agent can build the whole automation from a brief, trigger, waits, branches and email copy included, and the MCP server gives coding agents the same access, so a developer can ask Claude Code to wire up hit_plan_limit end to end. Our post on lifecycle emails with Claude Code walks through that.

If you are comparing directly, see Audienceful vs Customer.io, Audienceful vs Loops and Audienceful vs Klaviyo. For the full SaaS program around these flows, read SaaS lifecycle email marketing. For a wider list of tools, best lifecycle email software for SaaS compares more options.

FAQs

What is an event-based email?

An email sent to one person because of something they did or didn't do, such as signing up, abandoning a cart or failing a payment. The action is recorded as an event, and an automation listening for that event sends the email, usually after a short wait.

What's the difference between triggered and event-based emails?

In practice they mean the same thing. "Triggered" is the broader word and can include date triggers like birthdays or segment entry. "Event-based" usually means the trigger is a specific action reported by your app, store or billing system.

How do I send custom events to my email platform?

From your server, make an HTTP request to the platform's event endpoint with the person's email, the event name and any properties. In Audienceful that's a POST to https://api.audienceful.com/v2/automations/event with an X-Api-Key header, as shown in the trigger event docs. If you don't want to write code, Zapier can send the same event from thousands of apps.

Can I trigger emails from Stripe events?

Yes. Audienceful connects to Stripe directly and triggers automations on trial started, trial ending soon, payment failed, subscription cancelled and other billing events, with no webhook code. See Connect Stripe to Audienceful and the Stripe integration.

How do I stop over-emailing with triggers?

Give every flow an exit on its goal, rank flows so a money flow pauses a nudge, add a quiet window so nobody gets two automated emails within 24 hours, and exclude people in active onboarding or recovery flows from promotional campaigns.

Ready to wire up your first trigger? Create a free Audienceful account, connect Stripe or Shopify, and send your first custom event from the API.

Related guides

Email? Easy.

Audienceful is how smart companies do AI email newsletters, marketing automation, and transactional email.

The Audienceful editor