# How to send notifications to Slack

![](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FjDtbj4pJhA5N8yt5ESWf%2Fakenza%20%2B%20Microsoft%20Teams%20\(1\).png?alt=media\&token=6a178bd6-fdf3-45d6-a5fb-b90189d8529f)

In this tutorial, you will learn how to set up a **rule to send notifications to Slack.** We make use of the [device simulator](https://docs.akenza.io/how-to-connect-a-device/device-simulator), to test your rule set up right away. So just make sure, that you have your HTTP device created and available on your **Asset Inventory**.&#x20;

{% hint style="info" %}
Find out more about how to use the device simulator [here](https://docs.akenza.io/akenza.io/get-started/create-new-device/device-simulator).
{% endhint %}

The following steps are explained in more detail:

1. [Create a rule](#1.-create-a-rule)
2. [Create a webhook connector on your Slack channel](#2.-create-a-webhook-connector-on-your-slack-environment)
3. [Test your notification service](#2.-test-your-rule-alert-by-using-the-device-simulator)

### 1. Create a rule

Select as a **Rule Input** your created **HTTP** **device**. Add a logic connector to your rule by selecting the Logic Block *Comparison*. Connect the dots from your device to the comparison block. All available data sources from your device will appear on the dropdown of *Data source 1*. In this example, we have the following available data sources from the device simulator:

* Occupancy
* Temperature
* CO2

We choose *Temperature* as a data source, as we want to send a notification to **Slack** if a temperature threshold is reached.

In *Condition field 1* of your comparison block, you are free to choose the individual condition of your rule. In this example, we want to trigger an alert, if the temperature is smaller than **19** **degrees**.

Proceed now with adding the action connector *Slack* to your rule.

![Slack template](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FYkqneTtL3e1ySyGVP67s%2Fimage.png?alt=media\&token=d112fd96-13df-4abb-b3ac-f493aedb3927)

All Slack connectors which were already created in your organization are displayed as available connectors. For now, we create a new one. Choose *New Slack connector* and type in your specific information:

* Connector name (free text)
* Notification URL (Webhook URL of your Slack connector) See chapter 2, [how to create a webhook connector on your Slack channel](#2.-create-a-webhook-connector-on-your-slack-channel)
* Message (free text & optional payload data)

{% hint style="success" %}
Optional: Add **payload data** to your text by using such a syntax: {{myPropertyName}}. By adding payload data to your text, you will get informed about the actual measured value of your device. Use also the preview function, to preview your text content before you set it live.
{% endhint %}

Once your connector is filled out, select *Save connector*. Make sure, that you connect your connector to the comparison block. Proceed by selecting *Save Rule* and choose an appropriate name for your rule.&#x20;

Your notification rule is now saved and displayed on the **Rule Overview Page**.

### 2. Create a webhook connector on your Slack channel

Following steps are required to create your incoming webhook connector on your **Slack channel**:

1. Go to the Slack channel where you want to add the webhook and open *Channel Details*
2. Go to Integrations and add a new App
3. Search and select ***Incoming Webhooks***
4. Proceed with the Webhook by selecting *Configuration* and further *Add to Slack*
5. Select the channel name where the notification text is going to be sent to&#x20;
6. The slack app directory presents a **webhook URL** that maps to the channel. Copy and save the webhook URL select *Sav&#x65;**.***&#x20;
7. Paste the Webhook URL on the Slack Output Connector on akenza in the field *Notification URL* and select *Save connector.*

![Apps on Slack](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FDbDi3LpiKCUIrExVRPQw%2Fimage.png?alt=media\&token=a54846ca-e051-4400-802f-183bd8511cc6)

![Slack app directory](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FB5zhJvWhEoBL0bDnTPYd%2Fimage.png?alt=media\&token=f0120f54-3c7d-4b4d-a219-24df6e51d2a5)

{% hint style="info" %}
Learn more about [here](https://api.slack.com/messaging/webhooks), how to create your incoming webhook connector on **Slack**.
{% endhint %}

### 3. Test your notification service

To test your notification service, you now can send test data from the device simulator to your HTTP device. By selecting a temperature value smaller than the set 19 degrees on your rule, you will receive a notification on your **Slack channel**.

To send test data from the device simulator to your HTTP device, you need to copy the **Uplink URL** from your HTTP device. Go to *Asset Inventory*, select your HTTP device, and open *API-Configuration*.

Copy the *Uplink URL* and insert this URL on the Uplink URL field on the [device simulator](https://docs.akenza.io/how-to-connect-a-device/device-simulator).

![API-configuration](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FrPlfPHJoadI1uAmPwwOB%2Fimage.png?alt=media\&token=6bc07f68-2a5f-47fa-8ee9-802ac5e1ff47)

In this example, we choose a temperature value of 18 degrees that the rule gets triggered. Proceed by selecting *Send Message.* Check your Slack channel with the incoming notification.

![Slack channel notification](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2F1tFa6yyweIuj57UeKlcz%2FPasted_Graphic_9.jpg?alt=media\&token=42ae3a40-fae7-4fed-8a4d-dc13533e6f34)

**Congratulations,** you have successfully created a Slack notification service on akenza.&#x20;


---

# 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://docs.akenza.io/akenza.io/tutorials/create-notifications/how-to-send-notifications-to-slack.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.
