Quick overview
This workflow monitors a Gmail inbox, uses OpenAI to classify and summarize incoming emails, drafts sales replies in Gmail, and creates or updates HubSpot contacts and deals for qualified new leads while sending you notification emails for new leads, replies, and items needing manual review.
How it works
- Triggers every minute when a new message arrives in the Gmail inbox (excluding promotions, social, and forums).
- Skips emails already processed in previous executions, filters out newsletters/auto-replies and your own messages, and extracts a cleaned plain-text body and customer email.
- Sends the email content to OpenAI to classify it as a new lead, a customer reply, or other, and returns a structured summary and confidence score.
- Routes the email based on classification confidence and basic safety checks (for example, avoiding replies/forwards and requiring a customer email address).
- For qualified new leads, uses OpenAI to write a reply, saves it as a Gmail draft in the same thread, upserts the contact in HubSpot, creates a HubSpot deal, and emails you a notification with the outcome.
- For customer replies from known HubSpot contacts (excluding UNQUALIFIED), updates the HubSpot lead status to CONNECTED and emails you a notification.
- For anything ambiguous or missing key data, emails you an alert indicating the message needs manual review and does not create a draft or HubSpot record.
Setup
- Connect Gmail OAuth2 credentials for the Gmail trigger and all Gmail actions (draft creation and notification emails).
- Create and add a HubSpot App Token credential with permission to read and write contacts and deals.
- Add an OpenAI API credential for the OpenAI chat model used for classification and reply drafting, and select a model you have access to.
- Replace all placeholder values in “Your business details” (company info, notify email, ownEmails, and optional signature, deal stage, and confidence threshold).
- If you receive web form emails from a form service address, add those sender addresses to the formSenders list so the workflow can extract the real customer email.