Airtable lead capture chatbot for n8n
An n8n chatbot that saves website leads to an Airtable base, updating one record per email instead of creating duplicates.
Prerequisites
- An n8n instance, cloud or self-hosted
- An Airtable base with a Leads table (fields listed in step 1)
- An Airtable personal access token with data.records:read and data.records:write on that base
- An OpenAI API key (or another chat model credential)
- Your FAQ or services copy as plain text
A chat widget that answers visitor questions and saves leads as records in an Airtable base. It suits teams whose pipeline already lives in Airtable, with views, linked records and automations built around it, rather than a flat spreadsheet.
What you'll build
The bot answers from your own content and captures a lead once it has an email. Calling the capture tool again later in the same conversation, say when the visitor gives their name, updates the same record by email instead of creating a second one.
How it works
- A webhook receives each widget message and checks a shared secret.
- An AI agent answers from your
knowledgetext and calls the capture_lead tool once it has at least an email. - The tool validates the email and uses n8n's Airtable node to upsert a record matched on the
Emailfield. - There is no marketing list to protect, so there is no consent gate. Instead, once it has an email, the bot asks once, as its own message, whether it is okay to keep their details on file, and only checks
Consent Givenon a clear yes.
What it costs
The workflow is free to download and use. Your AI provider charges per conversation, and your n8n hosting and the plan for the service you connect apply as normal. For N8N Chat UI plans, see pricing.
Set it up
- Create your table. Make a table with these fields:
Email,Name,Interest,Summary,Session ID,Page URLandConsent Given. MakeConsent Givena checkbox and the rest single-line or long text. Field names must match exactly, because the tool maps to them by name. - Create the credential. Create an Airtable personal access token at airtable.com/create/tokens with
data.records:readanddata.records:writeon your base, then add it as an Airtable credential in n8n. - Import the workflow. Download the file with the button at the top of this page and import it with Workflows → Import from File. It holds the main chatbot and its tool workflow on one canvas, each in a labelled section.
- Move each tool into its own workflow. n8n tools call a separate workflow, so for each tool section below the main flow: select its nodes, copy them, create a new empty workflow and paste. Save it, then open the matching tool node under the agent and select that workflow. In the capture lead workflow, open Upsert lead record, attach your Airtable credential and choose your base and table. Use the "From list" pickers, or paste the IDs from your base's URL.
- Fill in Chatbot settings. Set
company_name,knowledgeand a randomwebhook_secret. - Add your AI credential. Open GPT-4.1 mini model and add your OpenAI credential. Swap the node for another chat model if you prefer.
Test it
Send a test message before you connect a widget. n8n's built-in chat panel needs a Chat Trigger, so it will not open for this workflow. Instead, click Test workflow, then send a POST request to the Test URL shown on the Chat webhook node:
curl -X POST 'YOUR_TEST_URL' \
-H 'Content-Type: application/json' \
-d '{"chatInput":"Hello","sessionId":"test-1","metadata":{"webhook_secret":"YOUR_SECRET"}}'The test URL listens for one request each time you click Test workflow. For a longer conversation, activate the workflow and send requests to the production URL, then read each run under Executions. Reuse the same sessionId to continue a conversation, because memory is kept per session.
Things to try:
- Ask a question and give no email. No record should be created.
- Give an email only. One record appears with the other fields blank.
- A few messages later, mention your name. The same record is updated, not duplicated.
- Agree to keeping your details on file.
Consent Givenis checked. If you decline or are unclear, it stays unchecked.
Add it to your site
Activate the workflow and use its production webhook URL as your widget's chat endpoint. Send the same secret in the widget metadata, for example metadata: { page_url: window.location.href, webhook_secret: 'YOUR_SECRET' }. The metadata docs explain how metadata reaches n8n.
Any chat front end that can POST chatInput, sessionId and metadata to a webhook and read { "output": "..." } back will work. N8N Chat UI is built for exactly this.
Troubleshooting
Records are duplicating instead of updating
Check the field is named exactly Email, with a capital E. The match is on that column, and a mismatch breaks it silently.
I get a permissions error from Airtable
Airtable tokens are scoped per base. Check your token has both data.records:read and data.records:write on the base you are using.
Should I use this or the Google Sheets recipe?
If your pipeline is already in Airtable, use this one. If you just need a flat list without that structure, the Google Sheets version is the simpler starting point.
The bot replies but the tool never runs
The tool node is not linked to its workflow. Open it and select the workflow you created from the tool section. A bare placeholder ID means it is still unlinked.
My conversations reset when n8n restarts
Memory is an in-memory buffer so the template works as soon as you import it. A restart or redeploy drops conversations in progress. Before a busy launch, swap Conversation memory for Postgres Chat Memory. Nothing else changes.
I get a 401 as soon as I test
The Request from your widget? check compares metadata.webhook_secret in the request with webhook_secret in Chatbot settings. If they differ, or the request has no metadata, the workflow returns a 401 before the agent runs.
Take it further
Every column, including Consent Given, is there so you can migrate into a real CRM later. Rows where consent is blank were not given it and should not be imported as if they were. See the HubSpot and ActiveCampaign versions.