ActiveCampaign lead capture chatbot for n8n, with tags and consent
An n8n chatbot that writes tagged contacts to ActiveCampaign from conversations and subscribes people to a list only after a separate, recorded opt-in.
Prerequisites
- An n8n instance, cloud or self-hosted
- An ActiveCampaign account with API access (the recipe only uses contacts, tags, lists and custom fields)
- Your ActiveCampaign API URL and API key, from Settings → Developer
- An OpenAI API key (or another chat model credential)
- Your FAQ or services copy as plain text
A chat widget that answers visitor questions, collects their details through conversation instead of a form, and writes a tagged contact straight into ActiveCampaign. Marketing consent is a separate, recorded opt-in, so your list stays clean.
What you'll build
A visitor asks a question and the bot answers from your own content. If the conversation warrants it, it asks for an email so someone can follow up. n8n then creates or updates the ActiveCampaign contact, applies tags describing what they were interested in and how ready to buy they sounded, and adds a short note for whoever picks it up.
Three things separate this from a form that emails you:
- The tags are specific.
interest:pricingandintent:hotcome from what the visitor said, so your existing automations can act on them without new segment logic. - The consent fields are populated. There is a timestamp and the exact wording the bot used when it asked.
- The note is readable. Whoever opens the contact gets the context in two sentences.
How it works
- A webhook receives each widget message and checks a shared secret.
- An AI agent answers from your
knowledgetext and decides when it has enough to save someone. - The capture_lead tool is a separate workflow that does the writing. It syncs the contact (so a returning email updates the record rather than duplicating it), writes custom fields, applies tags from a fixed vocabulary, adds the summary note, and subscribes to your list only if consent was given.
- The tags it can apply are
source:chat,interest:*,intent:*,objection:*,consent:explicit-chatorconsent:declined, and optionalsector:*tags you define.
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
- Get your API details. In ActiveCampaign go to Settings → Developer and copy your API key and your API URL. The URL is specific to your account and looks like
https://youraccount.api-us1.com. - Create the credential. In n8n, create an HTTP Header Auth credential with Name
Api-Tokenand Value your API key. The name is the HTTP header, not a label, so it must be exactlyApi-Token. - 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. Do the same for the setup section, then attach your ActiveCampaign credential to every HTTP Request node in both workflows.
- Run the setup. In the setup workflow, open Setup settings and paste your API URL into
ac_base_url. To tag leads by sector, add values tosector_tags, for example["property","employment"]; otherwise leave it as[]. Click Execute. It creates five custom fields and the tag vocabulary, then lists your lists with their IDs in the Setup summary output. Note the ID of the list for opted-in contacts. It is safe to run again, so re-run it if you add sector tags later. - Fill in the settings. In Chatbot settings set
company_name,consent_wording,knowledgeand a randomwebhook_secret. In the capture lead workflow's Tool settings setac_base_urlandlist_id. - 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.
ActiveCampaign refers to custom fields by numeric ID, and those IDs differ in every account. That is why setup is a workflow: it creates the fields and the tool looks their IDs up at run time, so you never go hunting for them.
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 contact should be created.
- Give an email and decline marketing. The contact exists, is tagged
consent:declinedand is not on your list. - Give an email and agree. The contact is on your list, tagged
consent:explicit-chat, with the audit fields filled in. - Come back with the same email. The contact is updated, not duplicated.
- Type a broken email. The bot should ask you to confirm it.
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.
How the consent handling works
Getting someone's email so you can answer their question, and adding them to a marketing list, are two different things. Treating them as one is how businesses end up with complaints they cannot answer. Many chatbot-to-CRM setups subscribe anyone who types an email address, which is a problem under UK GDPR and the EU equivalent, where consent has to be specific and freely given rather than bundled into something else the person wanted.
This workflow splits it in two. The agent never writes to the CRM directly. When it has an email and a reason to save it, it calls the capture_lead tool with consent_given set to false, and the contact is created but subscribed to nothing. Only after a separate, explicit yes does it call the tool a second time with consent_given set to true. That second call adds the contact to your list and records the exact wording the bot used and a timestamp.
The agent is told that ambiguity is not consent. "Sure, whatever" in reply to a bundled question does not count, and it is instructed never to bundle the two asks. Because the tool is a separate workflow, the gate is ordinary n8n branching that either fires or does not, not a suggestion to the model.
None of this is legal advice, and your obligations depend on where you and your contacts are. What it gives you is a record: if someone asks how they ended up on your list, the answer is on their contact record with a date against it.
Troubleshooting
A custom field is not being written, but there is no error
This is silent by design. The tool looks each field up by name against the IDs the setup created, and a name that does not resolve is skipped. If a field is consistently missing, the setup was not run, or it ran against a different account than your credential points at. Run it again and check the summary lists all five fields.
I get a 403 from ActiveCampaign
The credential's Name must be exactly Api-Token. A friendly name such as ActiveCampaign key fails with a 403 rather than a helpful message.
Contacts are created but tags are not applying
Tags have to exist before they can be applied, and the tool only applies tags from its fixed vocabulary. If you added sector tags later, run the setup again with the updated list.
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
The workflow includes a disabled node that sends an ActiveCampaign event named chat_ plus the visitor's interest, such as chat_pricing. Once enabled, your automations can trigger on what people said in chat. It is off by default because it needs event tracking switched on in your account and a separate event key and account ID from Settings → Tracking, not the API key you already added.
This recipe does not create deals, because deals need a CRM-enabled plan and the recipe is meant to work on the plans that only have contacts, tags and lists. To use a different CRM, swap the HTTP Request nodes in the capture lead workflow and keep the agent, the consent gate and the tag logic as they are. See also the HubSpot and Mailchimp versions.