# How to automatically send workflow errors as webhooks to a monitoring system

Exivity offers the possibility to [create notifications for workflows](/administration/notifications/workflow-notifications.md). Users can get notified when a workflow has finished successfully or when it has failed. In some scenarios, you may want to get informed by a Monitoring System about any *Failed Workflow* alerts. This is possible through webhooks.

## What are Webhooks?<br>

Webhooks are automated messages sent from one app to another when something happens.

![Continuous Polling](/files/P2Z1JYe7boiJ73vrYOef) ![Webhook](/files/L3QL9vHHhndRoxuw15fi)

**In simple words**: A webhook URL is provided by the receiving application (in this case, the Monitoring System), and acts like a phone number that the other application (in this case, Exivity) can "call" when an event happens. The data about the event is sent to the webhook URL in either JSON or XML format and it is known as the *Payload*. As seen in the diagrams above, there is no need to have continuous polling between the Monitoring system and Exivity when using webhooks.

The Monitoring System, receiving the notification through the chosen URL, not only knows an event occurred on another system, but it can also react to it.

## How to test your webhooks

In a real case scenario, you would have a webhook endpoint provided by your Monitoring System of choice. For the purpose of this tutorial, we are going to simulate that by using a mock endpoint.

One powerful tool that can get you started with the configuration of a webhook channel is [Hookdeck](https://hookdeck.com/). \
\
Hookdeck is a platform that helps you manage your webhooks and create mock endpoints for testing purposes.

All webhook events received through Hookdeck are monitored and readily available to you via the [Dashboard ](https://dashboard.hookdeck.com/events)or API.&#x20;

### Create a Hookdeck connection

You can easily create your first webhook with their [Get Started guide](https://hookdeck.com/docs/get-started).

{% hint style="info" %}
During the setting up process, make sure the Destination is configured as a mock endpoint, typically [`https://mock.hookdeck.com`](<https://mock.hookdeck.com&#xD;&#xA;&#xD;&#xA;>)
{% endhint %}

&#x20;After you have created your connection, it should look similar to this one:<br>

![Example of connection between Exivity and Hookdeck](/files/Imu4FO0hREy9N75J5cvP)

### Create a webhook channel

The next step is to [create a notification channel](/administration/notifications.md#channels) that uses this webhook endpoint.\
\
1\. To achieve this, open the Exivity GUI, navigate to the **Admin** > **My notifications** menu and select the **Channels** tab.

2\. Provide a **Channel name** for your channel and select the **Channel type** as *Webhook*.

3\. Go to your Hookdeck Dashboard and retrieve the URL for the webhook. This URL can be easily found by navigating to the [**Connections**](https://dashboard.hookdeck.com/connections) menu, under the **Source** name:\ <br>

![Copy the Webhook URL](/files/mO2bneGrSHshV97ul3na)

4\. Fill in the **Webhook URL** with the URL provided by Hookdeck:

![Creating a Webhook Channel](/files/GeBMVPDiscnzYi10itPh)

5\. Click the **Create** button.

### **Create a workflow notification**

Next, [create a notification for your workflow](/administration/notifications/workflow-notifications.md) and in the *Channel* section, add the Webhook Channel that you just created.

Also, make sure you fill in a suggestive **Name**, **Title** and **Description**, since you want to identify the *Error* status easily in your Monitoring System (or in this case, in the Hookdeck events Dashboard):

![Example of notification for a workflow that fails](/files/7bPTWjWQaiRomGmxRcKj)

### Test case using Hookdeck

Now that you have created a webhook channel and a notification for your workflow using that channel, you can test it to see that your Hookdeck mock endpoint catches your notifications successfully.\
\
1\. Ideally, none of your [workflows](/data-pipelines/workflows.md) would fail, but for testing purposes, we are going to make one of them fail. Select one of your workflows, and add a faulty step.\
\
For example, add an **Execute** type of step and fill in the following command:\
\
`ls -la`

{% hint style="info" %}
Obviously, the `ls -la` command is destined for Linux/Unix operating systems, not for Windows (which is the default OS for your Exivity installation), therefore it is going to fail.
{% endhint %}

![Example of a command that fails in your workflow](/files/RVd9TSybZY37t0ML8bh4)

2\. Click **Update** to add the new step, then you may also click the **Run Now** button if you don't want to wait until your Workflow is scheduled to execute.

3\. You should immediately see a new event in the Hookdeck events section in the Dashboard:

![Hookdeck events for your Connection](/files/gTQuvTKMxbCmDGq9xRm4)

{% hint style="info" %}
The *200 OK* status code indicates that the connection between Exivity and Hookdeck was successful, not that the Workflow has not failed.
{% endhint %}

4\. Select the most recent event (which is at the top of the list) and on the right side of your screen, you will see a window containing the Response/Payload in a JSON format. In the `body` section you can see the message from the notification you created to let you know when your workflow has failed:<br>

![The notification message got sent successfully to the Hookdeck endpoint](/files/mNVvxNNWtR8rFf7hHLGN)

Analogously, the same steps you have seen in this how-to guide will apply to sending your failed workflow notifications to a Monitoring System, except you will not use the mock endpoint provided by Hookdeck, but the webhook URL provided by your Monitoring System.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://olddocs.exivity.io/getting-started/how-to-guides/how-to-automatically-send-workflow-errors-as-webhooks-to-a-monitoring-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
