Quick overview
This workflow receives new lead submissions via a header-authenticated webhook, validates and normalizes the payload, prevents duplicate notifications using an n8n Data Table, then sends two Gmail emails (admin alert and lead acknowledgement) and returns a JSON response with the processing result.
How it works
- Receives a POST request on a header-authenticated webhook containing lead details.
- Normalizes the incoming fields (for example trimming the name and lowercasing the email) and rejects invalid payloads with an HTTP 400 JSON response.
- Checks an n8n Data Table log for an existing row with the same leadId to prevent sending notifications twice.
- If the lead was already processed, returns a JSON response indicating the request is a duplicate.
- If the lead is new, sends an admin notification email and a lead acknowledgement email through Gmail while allowing either email to fail without stopping the run.
- Logs email send statuses and errors back to the n8n Data Table and responds to the caller with a JSON success payload.
Setup
- Create and attach a Header Auth credential to the webhook and configure the calling form/CRM to send requests to the webhook URL with the required header.
- Connect a Gmail OAuth2 credential and select it in both Gmail email-sending steps.
- Create an n8n Data Table named
lead_notification_log with the expected columns (leadId, executionId, adminEmailStatus, adminEmailError, leadEmailStatus, leadEmailError, status, notifiedAt) and select it in both Data Table steps.
- Update the admin recipient email address (currently
[email protected]) and adjust the email subjects/bodies to match your branding.