Email marketing automation with AI follow-up and human handoff
A follow-up system that keeps each lead's email conversation in context and brings in a person when judgement is needed.
The problem
Following up consistently with many inbound leads by email is hard at scale. Tracking the context of each conversation by hand, across many threads at once, needs someone watching every one.
Challenges
Keeping context across many threads
Following up with many leads at once means each conversation has its own history. The system had to keep every thread's messages and events together, so a follow-up reflects what was already said and not just the fact that an email was sent.
Matching replies to the right conversation
Replies arrive by webhook and must land in the correct conversation thread before anything else can happen. Getting this wrong would send the wrong follow-up to the wrong lead, so matching and storing each reply reliably was central to the design.
Knowing when to stop and when to hand over
Automated messages should stop once a conversation is resolved, and complex or sales-ready conversations need a person. The build had to recognise both situations and flag them, rather than continuing to send follow-ups nobody wants.
How the system works
Data model
Five tables hold leads, contacts, conversations, messages and events separately. This keeps the full interaction history instead of just recording whether an email was sent.
First touch
A new prospect automatically receives an opening message when they enter the system.
Inbound handling
Replies arrive by webhook, are matched to the right conversation thread and stored as further messages in it.
AI summarisation
An AI agent periodically condenses long threads so a human reviewer can grasp the context without reading the whole exchange.
Automated follow-up
When a lead stays silent past a set time, the system writes and sends a suitable follow-up that keeps the conversation natural.
Human handoff
Conversations that need judgement, such as complex questions or sales-ready leads, are flagged and passed to a team member. Resolved conversations stop receiving automated messages.
Design decisions
A five-table data model
Leads, contacts, conversations, messages and events are kept in separate tables. This keeps the whole interaction history, rather than a single sent flag, and it gives the follow-up logic and the human reviewer the same reliable record to work from.
Summaries for the human reviewer
An AI step periodically condenses long threads so a person can catch up in seconds instead of rereading everything. We added it because handoffs are only useful if the person receiving one understands the context quickly.
Explicit human handoff and closure
Conversations needing judgement are flagged and passed to a team member, and closed conversations are marked so automated messages stop. Making handoff and closure explicit states means the system never guesses about when a person should take over.
Result in production
Every lead gets timely, contextual follow-up without a person tracking each conversation manually, and a human is brought in exactly when needed.
Every lead receives timely, contextual follow-up without a person tracking each conversation manually.
A person is pulled in exactly when a human touch is needed, such as a complex question or a lead ready to close.
Long conversations can be understood quickly from a summary, so handoffs lose less time.
Who this pattern fits
We built it for sales and marketing, but the approach fits any department managing similar volumes and coordination. The stack runs independently, is stable and suits small teams without dedicated platform engineers.
Tools used
n8n
Workflow runtime and orchestration; every scheduled job, webhook and branch lives here.
Unipile
Handles the sending of messages in production.
Supabase
PostgreSQL database, authentication and storage as the authoritative record.
Claude API
Reasoning and structured outputs; our default model for anything that has to be trusted.
Related service, use case and industries
Frequently asked questions
When does a person take over a conversation?
When a conversation needs judgement, such as a complex question or a lead ready to close, it is flagged and handed to a team member. Closed conversations are marked as such, which stops any further automated messages.
How does the system remember earlier messages?
Leads, contacts, conversations, messages and events are stored in separate tables, so the full interaction history is kept. Replies are matched to the right thread, and follow-ups are written with that history in mind.
Does this work with any email provider?
Yes. Unipile handles the sending, while the data model and the logic around it do not depend on a particular provider.