Webhook
7 min
Created by Movidesk on 7/2/2019 4:34 PM
Updated by Karine Moreira on 9/19/2024 2:22 PM

In this article, you will learn how to use webhooks in your Movidesk.

Webhooks are automations that allow you to send data from Movidesk to another system instantly, provided specific requirements are met. When the criteria are fulfilled, the information is sent and the receiver must be prepared to host it.

A webhook is triggered through triggers, which are fired based on specific conditions.

Therefore, to configure the webhook, you need to enable the same parameter as the triggers in the access profile: Settings > People > Access Profiles, select the desired person, and activate the option "Allow creating triggers".

There are two scenarios where you can use this automation, between two Movidesk systems or between Movidesk and another software.

 

Webhooks between two Movidesk domains

First, you will need to perform the integration between the two systems. Click here to learn how to complete this step. It is at this point that the trigger settings will be defined.

Once done, a new enabled trigger will be automatically created in the domain integrated with yours. It is this trigger that ensures the webhook functions.

 

Webhooks between Movidesk and another system

To send webhooks from Movidesk to another system, you need to go to Settings > Automation > Triggers. Click the + icon to create a new trigger.

Fill in the name you want to give the trigger and define its type. Then, complete the conditions that must be met for the webhook to be sent. For more information on how to use triggers, you can click here.

In the actions field, you will need to choose the action to trigger the webhook. A field will open for you to add the URL of the receiving location, which will be triggered to receive the defined data.

 

Execution Log

If you want to track the execution of webhooks, simply check under settings > automation > webhook - execution log.

A list of triggered webhooks will appear, including the last update, status, number of attempts, URL, error, trigger, and ticket number.

When the trigger is fired, the webhook is directed to a queue that is monitored every 30 seconds. In case of a webhook firing error, you will receive a notification in the bell icon, on the upper bar icons, to the right. The system will make four additional sending attempts, every 30 seconds.

Cases of delay in webhook firing are usually caused by business rules within the webhook call. The ideal scenario is to receive the webhook, store it in a database table, for example, and invoke a second program to handle the business rule. A webhook should respond "Ok" within a maximum of 3 (three) seconds (webhook system operating standard). If it does not, it is marked as failed.

There is a time control to prevent cases where the webhook gets stuck when there are no responses from external systems. The current limit is 2 minutes. After this period, the system cancels the operation with the message "Error: The operation was cancelled".

 

Execution Demonstration

When the webhook is triggered, the response will follow this structure:

{
  "Id": int,
  "Type": int,
  "Subject": string,
  "Urgency": string,
  "Status": string,
  "Origin": int,
  "IsDeleted": bool,
  "ServiceFirstLevel": string,
  "ActionCount": int,
  "ResolvedInFirstCall": bool,
  "SlaSolutionTime": int,
  "Actions": [
    {
      "Id": int,
      "Type": int,
      "Origin": int,
      "Description": string,
      "HtmlDescription": string,
      "CreatedBy": {
        "Id": string,
        "PersonType": int,
        "ProfileType": int
      },
      "IsDeleted": bool,
      "Attachments": [
         {
          "FileName": string,
          "Path": string
        }
      ]
    }
  ],
  "CustomFieldValues": [
    {
      "CustomFieldId": int,
      "CustomFieldRuleId": int,
      "Line": int,
      "Items": [
        {
          "CustomFieldItem": string,
          "StorageFileGuid": string
        }
      ]
    }
  ],
  "WebhookEvents": [
    {
      "Criteria": int,
      "Operation": int
    }
  ]
}