Guide

Build an Abandoned-Cart Recovery Agent

An AI agent on a dedicated inbox sends staged cart-recovery emails, reads buyer replies, escalates a discount, and stops the moment someone checks out.

Written by Nick Barraclough Product Manager

VerifiedCLI 3.1.20 · Nylas managed · last tested June 14, 2026

What is an abandoned-cart recovery agent?

An abandoned-cart recovery agent is a dedicated inbox paired with a model: it emails shoppers who added items but never bought, reads their replies, and stops the moment they check out. It runs the recovery sequence on its own schedule, classifies each response, and routes questions to a human. According to the Baymard Institute, the average documented cart-abandonment rate is about 70%, so this is the single highest-impact email an ecommerce team can automate.

Cart-recovery sequence: a reminder at one hour, social proof at one day, a discount at three days — and a checkout at any point stops the sequenceT+1hreminderT+24hsocial proofT+72hdiscountCheckoutstop sendinga checkout at any stage halts the sequence

The agent owns the nudging and the listening; it never touches the cart total or the payment. Checkout happens in your store, and the store tells the agent when an order lands so it can stop. Keeping money movement outside the agent's tool set means a shopper's reply can't talk it into issuing a refund — that action simply doesn't exist for the agent.

Why run cart recovery on an agent account?

A recovery agent should own its inbox so replies land where the agent reads, not in a marketer's personal mail. On an agent account, shop@yourstore.nylas.email is the agent's own address: every nudge it sends and every reply it gets lives in one managed identity, and you pause the whole campaign by suspending one grant. A shared marketing mailbox is the wrong home — the agent would see unrelated threads, and there's no clean per-campaign audit trail.

Isolation also caps the blast radius. Because the inbox starts empty — no contacts, no history — a poisoned reply has nothing private to steer the agent toward, and outbound rules cap how many messages it can send per hour. On the free tier you can run up to 5 such accounts — one per store or brand — without sharing state between them.

How do you stage the recovery emails?

Send three messages on a decaying schedule: a gentle reminder at T+1 hour, social proof at T+24 hours, and a discount only at T+72 hours. Leading with the discount trains shoppers to abandon on purpose, so the code holds it back until the first two nudges fail. A cron job runs the agent every 15 minutes and sends whichever stage each cart is due for.

The nylas email send command delivers each stage from the agent's own address. Pass the shopper's address, a stage-specific subject, and the body your template renders. One command replaces an SMTP relay and the deliverability setup behind it.

# Stage 3 — the discount nudge, sent only after T+72h with no checkout
nylas email send \
  --to shopper@example.com \
  --subject "Still thinking it over? Here's 10% off" \
  --body "Your cart is saved. Use SAVE10 at checkout within 48 hours."

Drive the stage selection from your cart store, not the agent's memory. For each open cart, compare the abandonment timestamp to now, pick the due stage, and record that you sent it so the next run doesn't repeat. Idempotency here is what stops a shopper getting the same email twice.

How does the agent read and classify replies?

Shoppers reply to recovery emails with questions, complaints, and unsubscribe requests. The agent polls its inbox, classifies each reply with a model into buy-intent, question, or stop, and routes accordingly. A buy-intent reply gets a fast human handoff; a question gets an answer; a stop request suppresses the address immediately. Classification takes 1 to 2 seconds per message.

The nylas email list --unread --json command returns the new replies as structured data the agent loops over. Read each one, classify it, act, and mark it read so it falls out of the queue. Treat every reply body as untrusted text the model summarizes, never as an instruction the agent obeys.

# Pull new replies for the agent to classify and route
nylas email list --unread --json

How do you stop sending when someone checks out?

Suppression is the most important rule in the whole agent: a shopper who buys must never get another nudge. When your store records a checkout, add that address to a suppression set the agent checks before every send. The same set holds anyone who replied stop, so one check covers both cases and the agent skips them in O(1) time.

Honoring opt-outs isn't optional — sending after an unsubscribe risks both your domain reputation and a violation of the CAN-SPAM Rule (16 CFR Part 316), which the FTC compliance guide says requires honoring an opt-out within 10 business days. Suppress on checkout, suppress on stop, and the agent stays on the right side of every shopper. A missed suppression is the one bug that turns a recovery campaign into a spam complaint.

Next steps