Quick overview
This workflow imports leads from an uploaded file into an n8n Data Table, sends a first-touch cold email through Gmail on a schedule or manually, then watches Gmail for replies and uses an OpenRouter LLM to classify interest and flag leads for human handoff.
How it works
- Receives an uploaded lead file via an n8n Form trigger and extracts rows from the file.
- Upserts each lead (name and email) into an n8n Data Table and sets the lead status to
new_leads.
- Runs on a schedule (or on-demand) to load the outreach subject and body, fetch leads with status
new_leads, and send each email via Gmail with the recipient’s name merged into the message.
- Records each sent email in a separate n8n Data Table with Gmail message/thread IDs and updates the lead’s status to
first_offer to prevent re-sending.
- Triggers when a new Gmail message arrives, matches the sender to a lead by email address, and stores the reply in the email inbox Data Table.
- Fetches the full thread history for that lead, keeps only the prospect’s received messages, and sends them to an OpenRouter-powered LLM to classify whether the prospect is already interested.
- If the classification indicates interest, updates the lead record to
handoff and sets a handoff destination value.
Setup
- Connect a Gmail OAuth2 credential for both sending emails and triggering on incoming replies.
- Add an OpenRouter API credential and select the model you want to use for reply classification.
- Create (or select) the two n8n Data Tables used by the workflow: one for leads and one for sent/received inbox messages, ensuring they include the referenced columns (email, name, status, thread IDs, and history IDs).
- Update the outreach copy in the offer configuration (subject and body) and ensure your lead file includes
name and email fields that match the extraction output.
- If using the form upload in production, copy the form URL and share it with whoever imports lead files.