WP Webhooks / Automations / Qualify Contact Form 7 leads with Gemini, HubSpot and Slack

Qualify Contact Form 7 leads with Gemini, HubSpot and Slack

Every Contact Form 7 submission goes to one n8n webhook the moment it passes the spam check. In n8n, Gemini sorts it into lead, support or spam and scores leads from 1 to 5. Leads are saved to HubSpot with a note and posted to your sales channel, support requests go to their own Slack channel, and spam stops there.

Why it goes through n8n

Contact Form 7 saves nothing to the database. Without a webhook, the notification email is the only copy of a lead, and a broken mail setup loses it without a trace. This build sends the submission out before the email, so HubSpot and Slack get the lead whether or not the email arrives.

n8n holds the Gemini, HubSpot and Slack connections, so WordPress only ever talks to one URL. Change the categories, swap the model or send support requests to a help desk later, and nothing changes in WordPress.

What you need first

  1. In n8n, import the template Qualify WordPress Contact Form 7 leads with Gemini, HubSpot and Slack. In its Settings node, describe your business in one sentence (Gemini scores leads against it), pick your sales and support channels, and check the field names match your form (the defaults match the stock Contact Form 7 form).
  2. Connect Gemini (an API key from Google AI Studio), HubSpot (a private app token with the contacts read and write scopes) and Slack (a bot token with chat:write, invited to both channels) inside n8n.
  3. Open the New Lead Webhook node, add a Header Auth credential with the name X-Webhook-Token and a long random token as the value, and copy the node's production URL.
  4. Import this build. The webhook arrives disabled: replace its endpoint URL with that production URL, give the import the same token when it asks for the credential, then enable it. The token lives in the Credentials Vault and is never part of a shared build.

What gets sent

{
  "your-name": "Ada Lovelace",
  "your-email": "[email protected]",
  "your-message": "Hi, I'd like a quote.",
  "form_title": "Contact form 1",
  "page_url": "https://example.com/contact/"
}

wpcf7_before_send_mail hands over the form, an abort flag and the submission. args.2.fields.your-name, args.2.fields.your-email and args.2.fields.your-message keep their names, args.0.title becomes form_title and args.2.meta.url becomes page_url. Nothing else travels, because unmapped fields are dropped.

If your form has more fields (phone, subject, a consent box), map args.2.fields.your-phone (or whatever the field is called) to the same name. The template shows every extra field to Gemini and puts it into the alert and the HubSpot note on its own, so there is nothing to change in n8n.

Why this hook

Contact Form 7 validates the fields and runs its spam check first, then fires wpcf7_before_send_mail, and only then sends the email. Bot spam never leaves WordPress, Gemini catches the human-written pitches that get past it, and a failed email no longer means a lost lead.

If a delivery fails

Delivery is asynchronous, so the visitor never waits on n8n. A failed POST is retried 5 times (1m, 2m, 4m, 8m) and every attempt is kept in the delivery log with the full request, which means the lead itself. If n8n was down for the whole ladder, hit Replay once it's back.

A 200 from the webhook node only means n8n accepted the submission. Check n8n's own execution list to see how each submission was sorted. If Gemini is down, the lead still goes to sales unscored, and if HubSpot rejects a lead, the Slack alert says why.

/ The conversation

This build was not assembled by hand. Its author described what they wanted in Build with AI, and the agent read the site, planned the work and applied it. This is that conversation.

model gemini-3.7-flash via hosted AI credits
Author

When someone submits a Contact Form 7 form, send the lead to n8n https://n8n.flowsystems.pl/webhook/94414065-21aa-4e75-b6fc-c4a31fd74ccc — after the spam check, before the mail is sent. Send your-name, your-email and your-message under the same names, plus the form title as form_title and the page URL as page_url. Use the "n8n lead webhook token" credential. No code glue, just mapping.

Build with AI

Checking the captured payload for Contact Form 7 and retrieving stored credentials...

Build with AI

I'll configure a new webhook listening to Contact Form 7 submissions on wpcf7_before_send_mail (which runs after spam verification and before email dispatch), attach your stored "n8n lead webhook token" credential (#98), and map the form fields, form title, and page URL directly to the payload. I've set it to deliver asynchronously in the background.

Published by the author on purpose. Tool output and raw payloads never travel with a shared build, and secrets never leave the site they were created on.

/ Abilities used (5)

  1. create_webhook Create disabled webhook for Contact Form 7 → n8n Lead
  2. assign_credential Attach stored 'n8n lead webhook token' credential
  3. set_mapping Map form fields, title, and page URL
  4. test_dispatch Send a test dispatch using the captured example payload
  5. enable_webhook Enable the webhook to go live

Each of these is a real ability the agent can call — see the docs for what each one does.

/ What runs

Contact Form 7 → n8n Lead
WordPress fires
wpcf7_before_send_mail
Field mapping
5 fields mapped
Queued, then sent
POST https://n8n.flowsystems.pl/webhook/94414065-21aa-4e75-b6fc-c4a31fd74ccc with your credential

Every attempt is retried on its own schedule and written to the delivery log.

WordPress fires the action wpcf7_before_send_mail, the payload is mapped and sent as POST to n8n.flowsystems.pl. The delivery is queued and sent in the background, so the visitor never waits. Along the way authentication comes from a credential you supply on import.

/ How it is configured

Contact Form 7 → n8n Lead
wpcf7_before_send_mail

/ Field mapping

args.2.fields.your-name your-name
args.2.fields.your-email your-email
args.2.fields.your-message your-message
args.0.title form_title
args.2.meta.url page_url

/ Authentication

This build authenticates with a credential you supply on import. The shared file carries the name and type only — never the secret.

  • n8n lead webhook token — api_key

/ Use this build

Download the file, then in WordPress open Webhook Actions → Webhooks → Import and drop it in. Anything needing authentication asks you to pick or create a credential as it imports — see Import & Export for what travels with a build and what does not.

A like sends 20 AI credits to whoever published this.

/ Published by

Flow Systems

/ Questions

Do I need a paid plan for this build? +
No. Everything a build can contain — webhooks, triggers, field mapping, conditions, retries, chains and Code Glue snippets — is in the free plugin from 3.0.0 on. A paid plan buys hosted AI credits and external cron, neither of which an imported build needs.
How do I use it on my own site? +
Download the JSON, then in WordPress open Webhook Actions → Webhooks → Import and drop the file in. Anything that needs authentication asks you to pick or create a credential during the import — secrets are never part of a shared build.
Does the build contain the author's API keys? +
No. Export carries credential metadata only — the name, the type and a masked hint — never the secret itself. The Credentials Vault is write-only over the API by design.
Publish

Publish your automation and get 50 AI credits,
+20 for each like.

$ wp plugin install flowsystems-webhook-actions --activate