Module Webhook

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search

Introduction

The module WebHook add the possibility to send a JSON message to an external URL, on a triggered Dolibarr event.

Installation

This module is included with the Dolibarr distribution, so there is no need to install it.

Configuration

To use this module, you must first enable it using an administrator account, via the menu option "Home - Setup - Modules".

Choose the tab where the module is listed. Then click on "Activate".

The module is now activated.

If a cog icon appears Cog circle.svg on module thumb or at end of the line of the module, click on it to access the setup page specific to the module.

Add a target

The only configuration needed for this module is adding a target. This is done by going into the module configuration, then click on the menu target. Then just click on the plus sign on the top right of the page, fill one or multiple trigger event and to add an URL to the site we want to post the JSON. You can find information on Trigger event on the wiki page Triggers.

Exemple:

Image of Webhook configuration.png

Execution

So once setup is done, each time a business event occurs in Dolibarr for the triggers defined into the setup, a call will be done to the targeted URL. The message will be a JSON message like this example:

{
   "triggercode" : "TRIGGER_CODE",
   "object" : {DolibarrObject}
}

Exemple of message sent by Dolibarr when the event COMPANY_CREATE is executed:

{
   {
     "triggercode":"COMPANY_CREATE",
     "object":
       {
          "id":39,"entity":1,"element":"societe","fk_element":"fk_soc","table_element":"societe","table_element_line":"","ismultientitymanaged":1,
          "import_key":"","array_options":{"options_height":"","options_weight":"","options_prof":"","options_birthdate":false},
          "restrictiononfksoc":1,"context":[],"canvas":"","ref_ext":"","status":"1","country_id":"117","state_id":"0",
          "multicurrency_code":"EUR","note_public":"","note_private":"","comments":[],"name":"Test Webhook",...
       }
   }
}

...