Quick overview
This workflow receives inbound web form leads via webhook, validates and scores them using the OpenAI Chat Completions API, creates a Gmail draft reply for high-fit leads, and logs both accepted and rejected submissions to Google Sheets.
How it works
- Receives an inbound lead submission as JSON via a POST webhook.
- Normalizes the payload, validates required fields (including email and minimum message length), and routes invalid submissions to a Google Sheets “Rejected” log.
- Sends valid lead details and your ideal-customer criteria to the OpenAI Chat Completions API to generate a JSON score, a short reason, and a suggested reply draft.
- Parses the model response and assigns a status, falling back to a needs_human status if the model call fails or returns invalid JSON.
- Creates a Gmail draft addressed to the lead when the score meets your threshold so a human can review and send it manually.
- Appends every scored lead (including low-fit and needs_human) to a Google Sheets “Leads” sheet with the score, reason, and status.
Setup
- Configure the inbound form or source system to POST lead JSON to the workflow’s production webhook URL.
- Add an HTTP Header Auth credential for the OpenAI-compatible API (Authorization: Bearer <API key>) and update the request URL if you use a non-OpenAI provider.
- Connect your Gmail account for draft creation.
- Connect Google Sheets, set the spreadsheet URL/ID in both Sheets nodes, and create “Leads” and “Rejected” sheets with matching columns (for example: received_at, name, email, company, message, score, reason, status).