Workflow Automation

How to Use Pipedrive Webhooks for Custom Integrations

by Mike Haye
PipedriveSheets Creator
11/8/2025 · 0 views

I want to integrate Pipedrive with our custom internal tools. I've heard about webhooks but I'm not sure how to set them up or use them. Can someone explain webhooks in simple terms?

Answers (1)
00
Bruce Bignell
Expert
Community Leader
11/8/2025

Complete Guide to Pipedrive Webhooks

What Are Webhooks?

Webhooks are automated messages sent from Pipedrive to your server when specific events happen. Think of them as notifications that say "Hey, something just happened in Pipedrive!"

Example: When a deal is won in Pipedrive → Webhook triggers → Your server receives the data → You can do whatever you want with it (send to Slack, update your database, trigger emails, etc.)

Setting Up Your First Webhook:

Step 1: Create an Endpoint on Your Server

First, you need a URL that can receive webhook data. Here's a simple Express.js example:

// server.js
const express = require('express');
const app = express();

app.use(express.json());

app.post('/webhooks/pipedrive', (req, res) => {
  const event = req.body;

  console.log('Webhook received:', event);
  console.log('Event type:', event.event);
  console.log('Data:', event.current);

  // Process the event here

  // Always respond with 200 OK
  res.status(200).send('OK');
});

app.listen(3000, () => {
  console.log('Webhook server running on port 3000');
});

Step 2: Register Webhook in Pipedrive

Use the Pipedrive API to create a webhook subscription:

curl -X POST \
  'https://api.pipedrive.com/v1/webhooks?api_token=YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "subscription_url": "https://yourserver.com/webhooks/pipedrive",
    "event_action": "added",
    "event_object": "deal"
  }'

Available Webhook Events:

Object Events Use Case
deal added, updated, deleted, merged Track deal changes, sync with CRM
person added, updated, deleted, merged Sync contacts to marketing tools
organization added, updated, deleted, merged Update company databases
activity added, updated, deleted Sync calendar events
note added, updated, deleted Log communications

Real-World Use Cases:

Use Case 1: Send Slack Notification When Deal is Won

const axios = require('axios');

app.post('/webhooks/pipedrive', async (req, res) => {
  const event = req.body;

  if (event.event === 'updated.deal' && event.current.status === 'won') {
    const deal = event.current;

    await axios.post(process.env.SLACK_WEBHOOK_URL, {
      text: `🎉 Deal Won: ${deal.title} - $${deal.value}!`,
      channel: '#sales'
    });
  }

  res.status(200).send('OK');
});

Use Case 2: Create Customer in Billing System When Deal Closes

app.post('/webhooks/pipedrive', async (req, res) => {
  const event = req.body;

  if (event.event === 'updated.deal' && event.current.status === 'won') {
    const deal = event.current;

    // Get associated person
    const person = await getPipedriveParson(deal.person_id);

    // Create in Stripe
    const customer = await stripe.customers.create({
      email: person.email,
      name: person.name,
      metadata: {
        pipedrive_deal_id: deal.id,
        deal_value: deal.value
      }
    });

    console.log('Customer created in Stripe:', customer.id);
  }

  res.status(200).send('OK');
});

Use Case 3: Log All Deal Updates to Database

app.post('/webhooks/pipedrive', async (req, res) => {
  const event = req.body;

  if (event.event === 'updated.deal') {
    // Compare previous and current to see what changed
    const changes = {};

    for (const key in event.current) {
      if (event.current[key] !== event.previous[key]) {
        changes[key] = {
          old: event.previous[key],
          new: event.current[key]
        };
      }
    }

    // Save to your database
    await db.dealHistory.create({
      deal_id: event.current.id,
      changes: changes,
      changed_by: event.current.user_id,
      timestamp: new Date()
    });
  }

  res.status(200).send('OK');
});

Best Practices:

1. Always Respond Quickly

  • Pipedrive expects a 200 response within 5 seconds
  • Do heavy processing asynchronously
  • Use a queue system for complex operations
// Good pattern: Quick response + background processing
app.post('/webhooks/pipedrive', (req, res) => {
  const event = req.body;

  // Respond immediately
  res.status(200).send('OK');

  // Process in background
  processWebhookAsync(event);
});

2. Verify Webhook Authenticity (Security)

  • Check the user-agent header
  • Validate the request comes from Pipedrive's IP range
  • Use a secret token in your URL

3. Handle Duplicates

  • Pipedrive may send the same webhook multiple times
  • Use idempotency keys to prevent duplicate processing
const processedEvents = new Set();

app.post('/webhooks/pipedrive', (req, res) => {
  const eventId = req.body.meta.id;

  if (processedEvents.has(eventId)) {
    return res.status(200).send('Already processed');
  }

  processedEvents.add(eventId);

  // Process event

  res.status(200).send('OK');
});

4. Monitor and Log

  • Log all incoming webhooks
  • Track failures and retry
  • Set up alerts for high failure rates

Testing Webhooks:

Option 1: Use ngrok for Local Testing

# Install ngrok
npm install -g ngrok

# Start your local server on port 3000
node server.js

# In another terminal, create public URL
ngrok http 3000

# Use the ngrok URL in Pipedrive webhook settings
# Example: https://abc123.ngrok.io/webhooks/pipedrive

Option 2: Use Webhook Testing Tools

  • webhook.site - Generate temporary webhook URLs
  • requestbin.com - Inspect webhook payloads
  • Postman - Mock webhook requests

Debugging Common Issues:

Issue Cause Solution
Webhook not firing Subscription not created properly Check webhook list via API
Timeout errors Processing takes too long Move to background queue
Missing data Event doesn't include all fields Fetch full object via API
Duplicate events Normal behavior Implement idempotency

Pro Tip: Start with one webhook for one event type. Once it's working reliably, add more. Don't try to handle every event at once!

0
0

Sign in to answer

You must be signed in to post an answer.

Sign In
Asked by
Mike Haye
PipedriveSheets Creator
PipedriveSheets
54
KARMA