Quick overview
This workflow receives inbound leads via webhook, validates and normalizes the data, scores and routes the lead to a sales rep, checks for duplicates and upserts the contact in HubSpot, drafts an outreach email with OpenAI, notifies the rep via Slack and Gmail, and logs the result to Google Sheets.
How it works
- Receives a POST webhook request with inbound lead details.
- Validates required fields (like name and email) and returns a 400 JSON response if the payload is invalid.
- Normalizes lead fields (name, email, company, region, source, and company size), calculates a lead score and tier, and assigns the lead to a rep based on region and tier.
- Searches HubSpot for an existing contact by the lead data and flags the lead as a duplicate when a match is found.
- If the lead is new, requests an outreach email draft from the OpenAI Chat Completions API; otherwise, posts a duplicate warning to Slack.
- Upserts the contact in HubSpot for hot/warm leads or logs the cold lead to HubSpot, then notifies the assigned rep in Slack and emails them the AI draft via Gmail.
- Appends a routing log row to Google Sheets and returns a JSON webhook response with the assigned rep, tier, and duplicate status.
Setup
- Configure the Webhook trigger URL (POST
/inbound-lead) in your form, landing page, or source system to send the required lead fields.
- Add HubSpot OAuth2 credentials for searching and creating/updating contacts.
- Add Slack OAuth2 credentials and set the target channel/workspace used by the Slack notification and duplicate warning steps.
- Add Gmail OAuth2 credentials for sending the outreach draft to the assigned rep.
- Add an OpenAI API key via HTTP Header Auth (Bearer token) and confirm the model name in the OpenAI request.
- Add a Google Sheets Service Account credential, replace
REPLACE_WITH_YOUR_SHEET_ID, and ensure the target sheet (e.g. Sheet1) has matching columns for the appended log fields.