Table of Contents

  1. Introduction

  2. What Are Webhooks?

  3. Why Use Webhooks in Dolibarr?

  4. Understanding Dolibarr’s Webhook Capabilities

  5. Common Use Cases for Webhook Automation

  6. Enabling Webhooks in Dolibarr

  7. Creating Webhook Endpoints

  8. Securing Webhook Communications

  9. Working with Event Triggers in Dolibarr

  10. Receiving Webhooks in a Middleware

  11. Example: Automating Invoice Processing

  12. Example: Real-Time Order Notifications

  13. Using Webhooks for CRM Integration

  14. Connecting Dolibarr with Slack, Discord, or Email Alerts

  15. Advanced Workflows: Approval Chains and Task Creation

  16. Logging and Monitoring Webhook Activity

  17. Testing Webhooks Effectively

  18. Troubleshooting Webhook Issues

  19. Best Practices for Scalable Automation

  20. Conclusion


1. Introduction

Modern business applications thrive on automation. In Dolibarr ERP/CRM, automating repetitive tasks and triggering workflows based on system events is possible using webhooks. This guide explores how to configure, secure, and use webhooks within Dolibarr to streamline operations and integrate with external systems.


2. What Are Webhooks?

Webhooks are user-defined HTTP callbacks triggered by events. When a specified action occurs (e.g., a new invoice is validated), Dolibarr sends a POST request to a predefined URL, usually carrying a payload of data about the event.

Webhooks are often used for real-time notifications and automation between systems.


3. Why Use Webhooks in Dolibarr?

Benefits include:

  • Automating notifications

  • Real-time integrations

  • Reducing the need for polling APIs

  • Enabling event-driven systems

Examples:

  • Alerting an admin when a new order is placed

  • Automatically syncing data to external CRMs or apps

  • Triggering invoice validation workflows


4. Understanding Dolibarr’s Webhook Capabilities

Dolibarr includes basic webhook support via its trigger system. Developers can:

  • Hook into predefined actions

  • Use interface_99_modXXX_YYY.class.php classes

  • Customize behavior for modules like orders, invoices, products, etc.

Dolibarr does not offer a full UI for webhooks but provides programmatic access and customization.


5. Common Use Cases for Webhook Automation

  • Send invoice details to external billing services

  • Notify warehouse staff of new shipments

  • Integrate with Slack or Microsoft Teams

  • Push CRM lead data to third-party platforms

  • Trigger external scripts for PDF generation or reporting


6. Enabling Webhooks in Dolibarr

To activate webhook logic:

  1. Ensure developer mode is on in conf.php

  2. Navigate to /htdocs/core/triggers/

  3. Create or customize a trigger file

Example file: interface_99_modWebhook_Mytrigger.class.php


7. Creating Webhook Endpoints

Endpoints are servers that listen for webhook calls. You can build one using:

  • Node.js (Express)

  • Python (Flask/FastAPI)

  • PHP

Basic example in PHP:

$input = file_get_contents('php://input');
$data = json_decode($input, true);
file_put_contents('log.txt', print_r($data, true));

Ensure your endpoint is publicly accessible and supports HTTPS.


8. Securing Webhook Communications

To protect your system:

  • Use HTTPS to encrypt payloads

  • Include a shared secret in the header

  • Validate payload source IP

  • Log all webhook activity

Implement signature validation to avoid spoofed calls.


9. Working with Event Triggers in Dolibarr

Dolibarr uses internal events like:

  • BILL_VALIDATE

  • ORDER_CREATE

  • PRODUCT_CREATE

In your custom trigger, use run_trigger() to catch events and send a POST to your endpoint:

if ($action == 'ORDER_VALIDATE') {
  $payload = json_encode($object);
  file_get_contents('https://your-endpoint.com/hook?payload=' . $payload);
}

10. Receiving Webhooks in a Middleware

Middleware acts as a relay between Dolibarr and other services. Example:

  • Receive data from Dolibarr

  • Transform or filter it

  • Push it to a third-party API (e.g., Salesforce, Notion)

Middleware platforms: Zapier, Make.com, n8n, or a custom server.


11. Example: Automating Invoice Processing

Trigger: BILL_VALIDATE Workflow:

  1. User validates invoice

  2. Webhook sends data to invoice management tool

  3. Tool replies with confirmation or failure

  4. Dolibarr logs the response and updates status

This reduces manual syncing with external accounting tools.


12. Example: Real-Time Order Notifications

Trigger: ORDER_CREATE Use case:

  • Send message to Slack when a new order is placed

Workflow:

  1. Webhook sends JSON to middleware

  2. Middleware formats message

  3. Slack webhook posts message to sales channel


13. Using Webhooks for CRM Integration

Trigger: THIRDPARTY_CREATE, CONTACT_CREATE Use case:

  • Push new clients to external CRM

The webhook sends payloads to your CRM’s API, creating leads or customer profiles automatically.


14. Connecting Dolibarr with Slack, Discord, or Email Alerts

Use Zapier or a custom relay:

  • Format payload to readable message

  • POST to Slack/Discord via webhook URL

  • Send email via SMTP with triggered content

Add emoji reactions or timestamps for clarity.


15. Advanced Workflows: Approval Chains and Task Creation

Use webhooks to:

  • Create approval tasks in project management tools (e.g., Asana, Trello)

  • Notify supervisors when thresholds are reached (e.g., invoice > $10,000)

Workflow:

  1. Trigger fires

  2. Middleware checks conditions

  3. If condition met, task or alert is created


16. Logging and Monitoring Webhook Activity

Log webhook actions:

  • File logs in /var/logs/

  • Store metadata in Dolibarr extra fields

  • Use external services like Loggly or Datadog for monitoring

Log entries should include timestamps, response codes, and any errors.


17. Testing Webhooks Effectively

Use tools:

  • RequestBin or Webhook.site for inspecting payloads

  • Postman to simulate Dolibarr webhook calls

  • ngrok for testing locally behind firewalls

Simulate each event to verify flow before production use.


18. Troubleshooting Webhook Issues

Common problems:

  • HTTP 500 from endpoint (check error logs)

  • Invalid payload structure (compare schemas)

  • Timeouts (optimize processing time)

Always retry failed requests if they are critical.


19. Best Practices for Scalable Automation

  • Use queues (e.g., RabbitMQ) to process events asynchronously

  • Batch webhook events if volumes are high

  • Apply exponential backoff for retries

  • Separate critical and non-critical workflows

Document your webhooks and provide fallback mechanisms.


20. Conclusion

Webhooks enable real-time automation and powerful integrations in Dolibarr. By setting up secure endpoints, designing intelligent workflows, and monitoring activity, you can eliminate redundant tasks and boost your system’s responsiveness. Whether for internal processes or third-party communication, webhooks make your Dolibarr installation truly dynamic.