See llms.txt for all machine-readable content.

Back to Templates

Score inbound B2B leads with OpenAI, Gmail, and Google Sheets

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

  1. Receives an inbound lead submission as JSON via a POST webhook.
  2. Normalizes the payload, validates required fields (including email and minimum message length), and routes invalid submissions to a Google Sheets “Rejected” log.
  3. 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.
  4. Parses the model response and assigns a status, falling back to a needs_human status if the model call fails or returns invalid JSON.
  5. Creates a Gmail draft addressed to the lead when the score meets your threshold so a human can review and send it manually.
  6. Appends every scored lead (including low-fit and needs_human) to a Google Sheets “Leads” sheet with the score, reason, and status.

Setup

  1. Configure the inbound form or source system to POST lead JSON to the workflow’s production webhook URL.
  2. 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.
  3. Connect your Gmail account for draft creation.
  4. 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).