## Introduction
For sales teams, managing leads efficiently and accurately is critical for closing deals faster and improving pipeline visibility. Pipedrive, a popular CRM, supports lead and deal management but lacks out-of-the-box automation for granular auto-tagging of new leads based on custom criteria. Manually tagging leads is time-consuming and prone to errors, leading to missed segmentation and mistargeted sales efforts.
This article provides a step-by-step technical tutorial on how to automate the process of auto-tagging new leads in Pipedrive using n8n, a powerful open-source workflow automation tool. Sales operations specialists and automation engineers will benefit from this guide by implementing a scalable workflow that tags leads dynamically upon creation, enabling more precise segmentation, follow-ups, and reporting.
—
## Tools and Services Integrated
– **Pipedrive CRM**: Source of new leads.
– **n8n**: Workflow automation tool managing the entire auto-tagging process.
—
## Problem This Automation Solves
– Eliminates manual lead tagging, saving sales reps’ time.
– Applies consistent tagging rules for better lead segmentation.
– Enables dynamic and custom tagging based on lead attributes (e.g., lead source, location, deal value).
– Ensures tags are applied immediately after lead creation, streamlining sales workflows downstream.
—
## Prerequisites
– An active Pipedrive account with API access.
– An n8n instance (cloud or self-hosted) with internet access.
– Basic familiarity with Pipedrive API and n8n interface.
– API key generated from Pipedrive (found under Settings > Personal > API)
—
## Technical Tutorial: Building the Auto-Tagging Workflow in n8n
### Step 1: Set Up the Trigger for New Leads in Pipedrive
n8n currently does not provide a native Pipedrive webhook trigger. Therefore, we will use Pipedrive’s built-in Webhooks feature to notify n8n when a new lead (person) is created.
**Actions in Pipedrive:**
1. Navigate to Settings > Tools > Webhooks.
2. Create a new webhook with:
– Event: “Added a new person”
– URL: Your n8n webhook node URL (we will create this next)
3. Save the webhook.
This setup ensures that every time a new lead is added to Pipedrive, Pipedrive sends a POST request with lead details to n8n.
### Step 2: Create a Webhook Node in n8n
1. In your n8n editor, add a new **Webhook** node.
2. Configure it as:
– HTTP Method: `POST`
– Path: `/pipedrive-new-lead` (or any unique identifier)
3. Copy the full webhook URL for use in Pipedrive’s webhook setup.
This node listens for incoming HTTP POST requests from Pipedrive whenever a new lead is created.
### Step 3: Parsing Incoming Lead Data
The webhook payload from Pipedrive will contain lead details. To process it:
1. Add a **Set** node after the webhook to map and extract relevant fields from the webhook payload:
– Person ID
– Name
– Email
– Phone
– Lead source (custom field if used)
– Any other custom fields relevant for tagging
Example expressions:
– `{{$json[“current”][“id”]}}` for Person ID
– `{{$json[“current”][“name”]}}` for Name
This prepares data for decision-making.
### Step 4: Define Tagging Logic Using If Nodes
With lead data parsed, next is to decide which tag(s) to apply. This can be based on any lead attribute.
Example scenarios:
– If lead source = “Website”, tag as “Web Lead”
– If lead location = “Europe”, tag as “EU Lead”
– If deal value > $10,000, tag as “High Value”
Implementation:
1. Use multiple **If** nodes connected in sequence or parallel.
2. Each If node evaluates one condition.
3. For conditions satisfied, pass the person ID and tag name to the tagging node.
Example If node condition (for lead source):
– `{{$json[“lead_source”]}} == ‘Website’`
### Step 5: Create Tags in Pipedrive (Optional)
If the tag doesn’t exist, you need to create it first. You can pre-create tags manually in Pipedrive or automate tag creation:
1. Use Pipedrive API to list existing tags.
2. If tag not found, create it using `POST /organizationFields` or relevant API endpoint.
For simplicity, assume tags are pre-created.
### Step 6: Apply Tags to Leads Using Pipedrive API
To attach a tag to a person in Pipedrive:
– Use the **HTTP Request** node in n8n.
– Method: `PUT`
– URL:
`https://api.pipedrive.com/v1/persons/{personId}?api_token={your_api_key}`
– Body (JSON):
“`json
{
“label”: “TagName”
}
“`
Note: Pipedrive’s native API doesn’t have a direct ‘add tag’ endpoint; tags are managed as a field or custom field. Usually, tags are stored as a custom field or label string field.
Check your Pipedrive setup for how tags are implemented (often as a string list in a custom field named “label” or “tags”).
**Example:**
– Fetch person
– Update the tags field appending the new tag (taking care not to overwrite existing tags)
Implementation details:
1. Use an HTTP Request node to fetch current tags.
2. Append new tag to the list (unique values only).
3. Use HTTP Request node to update the person with new tags.
Sample n8n workflow snippet for this:
– HTTP Request node to GET person details
– Function node to merge the tags
– HTTP Request node to PUT update
### Step 7: Handling Multiple Tags
If multiple conditions result in different tags, consolidate tags in a Function node:
“`javascript
const tags = (items[0].json.currentTags || ”).split(‘,’).map(t => t.trim()).filter(t => t !== ”);
const newTags = […new Set([…tags, …items.map(i => i.json.tagName)])];
return [{ json: { combinedTags: newTags.join(‘, ‘) } }];
“`
Update the person’s tag field using combinedTags.
### Step 8: Error Handling and Robustness
– Use n8n’s built-in error workflow to handle API failures.
– Add retries on HTTP request nodes for transient network errors.
– Validate incoming webhook data before processing.
– Log failed attempts to a Slack channel or email for monitoring.
### Step 9: Testing the Workflow
– Create test leads in Pipedrive with various attributes.
– Confirm the webhook fires and triggers the workflow.
– Check if the correct tags are applied as expected.
– Debug using n8n’s execution logs.
### Step 10: Deployment and Scaling
– Deploy n8n on a reliable server or managed cloud.
– Monitor API rate limits from Pipedrive.
– For high lead volumes, consider batching or queueing updates.
– Add support for additional tagging rules by extending the If nodes or using a database-driven rule set.
—
## Summary
Automating auto-tagging of new leads in Pipedrive using n8n eliminates manual work and enforces consistent lead segmentation essential for targeted sales efforts. By combining Pipedrive webhooks, conditional logic in n8n, and Pipedrive API updates, sales teams gain real-time tagged lead data, improving pipeline accuracy and enabling smarter follow-ups.
**Bonus Tip:**
Consider extending this workflow to send automated Slack alerts or emails to sales reps when high-value or prioritized leads are tagged, creating an immediate call-to-action for the team.
—
This detailed guide equips CTOs and automation specialists with a practical framework to harness n8n for CRM lead hygiene and operational efficiency.