Pipedrive lead capture chatbot for n8n that creates deals
An n8n chatbot that turns interested website visitors into a Pipedrive person with a linked deal and a note carrying interest, intent and a conversation summary.
Prerequisites
- An n8n instance, cloud or self-hosted
- A Pipedrive account with at least one pipeline and stage
- A Pipedrive API token, from Settings → Personal preferences → API
- The numeric ID of the stage new deals should land in
- 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, once it has an email and a real reason, puts a person and a linked deal into your Pipedrive pipeline.
What you'll build
The bot answers from your own content. When a visitor gives an email and there is a reason to follow up, n8n creates a person in Pipedrive (or finds the existing one) and a deal linked to that person in the stage you choose. A note on the deal carries what they were interested in, how ready to buy they sounded, any objection, and a summary.
Why a deal, not just a contact. Pipedrive is organised around deals. A recipe that only created a person would technically work, but it would put nothing in front of a salesperson the way they actually use Pipedrive.
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 enough. - The tool searches for a person by exact email, creates one if none exists, creates a deal linked to that person in your chosen stage, and adds a note to the deal.
- The agent calls the tool once per conversation. Every call creates a new deal, so the prompt tells it not to call again just because the conversation continues. A chatbot has no reliable way to know whether an existing open deal is the same enquiry, so creating a fresh deal is the honest behaviour.
- There is no consent gate, because Pipedrive has no marketing list to protect. Interest, intent and objection go onto the deal as a note, since Pipedrive has no lightweight tagging.
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
- Find your stage ID. You need the numeric ID of the stage new deals land in, not its name. Make one authenticated GET request to
https://yourcompany.pipedrive.com/api/v1/stages?api_token=YOUR_TOKENand note theidof the stage you want. - Create the credential. Pipedrive authenticates with a query parameter, not a header. In n8n, create a Query Auth credential with the parameter name
api_tokenand your token as the value. - 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. Attach the Query Auth credential to every HTTP Request node in the capture lead workflow.
- Fill in the settings. In Chatbot settings set
company_name,knowledgeand a randomwebhook_secret. In the capture lead workflow's Tool settings setpipedrive_domain(the subdomain in your Pipedrive URL) andpipeline_stage_idfrom step 1. - 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 person or deal should be created.
- Give a new email. A person and a linked deal should appear in your stage, with a note on the deal.
- Use an email that already exists. The same person is reused and a new deal is still created.
- Keep chatting after the capture. The bot should not call the tool a second time.
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
I get a 401 or an invalid token error
Check the credential is a Query Auth credential, not Header Auth. Pipedrive needs the token in the URL, and a header-based credential fails even with the right token.
The deal is not landing in the stage I expect
Check pipeline_stage_id is a real stage ID from your account, not a pipeline ID or a guess.
A returning visitor got a duplicate person
The search matches on exact email, so check the email is consistent between conversations (same casing, no extra spaces).
Why does every capture create a new deal?
See the explanation above. It is deliberate, and it is why the agent is told to call the tool only once per conversation.
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
Endpoints used here are Pipedrive's v1 API for persons, deals and notes. Pipedrive has been moving some endpoints to v2, so check its API reference if you see deprecation notices. See also the HubSpot and ActiveCampaign versions.