# Sending data to a Slack channel

{% hint style="warning" %}
This documentation references external sources.

Nexthink does not control the accuracy of third-party documentation or external updates that can result in inconsistencies.

Report any errors or inconsistencies to [Nexthink Support](https://support.nexthink.com/).
{% endhint %}

This document demonstrates how to send data to a Slack channel, using Nexthink webhook capability, to stand out from other messages in the channel.

## In Slack <a href="#sendingdatatoaslackchannel-inslack" id="sendingdatatoaslackchannel-inslack"></a>

1. [Create a new Slack app](https://api.slack.com/apps?new_app=1) in the workspace where you want to post messages.
2. From the **Features** page, toggle **Activate Incoming Webhooks** on.

<figure><img src="/files/hvU09mMrbANPCd5mtHEQ" alt="Activating incoming webhooks in Slack"><figcaption></figcaption></figure>

3. Click **Add New Webhook to Workspace**.

<figure><img src="/files/BDaElRfp9b9sIsyDh6dr" alt="Adding new webhook to workspace" width="544"><figcaption></figcaption></figure>

4. Pick a channel that the app will post to, then click **Authorize**.

<figure><img src="/files/Ttbccbg6ylsBgm0Dg4m1" alt="Authorization" width="442"><figcaption></figcaption></figure>

5. Copy the generated [Incoming Webhook URL](https://api.slack.com/messaging/webhooks#posting_with_webhooks) for future reference. That is, for the [connector credential](#configuring-a-connector-credential-for-the-servicenow-incident-creation) and [webhook configuration](#configuring-a-webhook-for-servicenow-incident-creation) in the Nexthink web interface.\
   **Webhook URL** example: `https://hooks.slack.com/services/T00000000/BXXXXXXXXXX/PLVXXXXXXXXXXXXXXXXXXXXX`

<figure><img src="/files/VrmdZJa2deVLdwmQp2it" alt="Webhook URL" width="544"><figcaption></figcaption></figure>

## In Nexthink <a href="#sendingdatatoaslackchannel-innexthink" id="sendingdatatoaslackchannel-innexthink"></a>

From the Nexthink web interface:

* [Configure a connector credential for the webhook](#postingamessageinzoom-configuringaconnectorcredentialforzoomcredentialzoomtrue)
* [Configure and test the webhook to post messages in Slack](#postingamessagetoanmsteamschannel-configuringawebhookformschannel)

### Configuring a connector credential for Slack <a href="#postingamessageinzoom-configuringaconnectorcredentialforzoomcredentialzoomtrue" id="postingamessageinzoom-configuringaconnectorcredentialforzoomcredentialzoomtrue"></a>

From the [connector credential](/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/connector-credentials.md) configuration page, fill out the fields using the information from the connection you created in Slack.

1. Choose the **HTTPS** option from the **Protocol** drop-down.
2. Paste the root `https://hooks.slack.com/` into the **URL address** field from [Webhook URL](#sendingdatatoaslackchannel-inslack) from Slack configuration.
3. Choose **Basic** option from the **Authorization** drop-down.
4. Type in `Test` in the fields **Username** and **Password**, as these fields are not required when configuring Incoming Webhooks for Slack.
5. **Save** the credential.

### Configuring a webhook for Slack channel <a href="#postingamessagetoanmsteamschannel-configuringawebhookformschannel" id="postingamessagetoanmsteamschannel-configuringawebhookformschannel"></a>

From the [webhook configuration page](/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks.md), fill out the fields using the information from the connection you created in Slack and the connector credential defined in Nexthink:

1. Fill in the **NQL Condition** following the [Configuring webhook NQL conditions](/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks/configuring-webhook-nql-conditions.md) documentation.

   * After filling in the NQL Condition, the system lists the [allowed placeholders](/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/managing-webhooks/configuring-webhook-fields_-method-resource-and-payload.md#configuringwebhookfields-method-resource-andpayload-usingdatamodelvariablesasplaceholdersinthepayloa) for the **Payload**.

   ```
   alert.alerts
   | where monitor.tags contains "web-applications"
   | where alert.context contains "*Salesforce*" or alert.context contains "*Microsoft*"
   | list alert.monitor.name, alert.status, monitor.tags, alert.context, trigger_time, recovery_time, alert.monitor.thresholds, monitor.priority, alert.trigger_values, alert.trigger_reference_value, alert.recovery_values, alert.context, device_view_link, issue_view_link, device.name
   ```
2. Choose the configured [connector credential](#postingamessageinzoom-configuringaconnectorcredentialforzoomcredentialzoomtrue) for Slack from the **Credentials** drop-down.
3. Select the **POST** from the **Method** drop-down.
4. Paste into the **Resources** field, the URL endpoint from the [Slack configuration](#sendingdatatoaslackchannel-inslack) without the root URL address. For example:\
   `services/T00000000/BXXXXXXXXXX/PLVXXXXXXXXXXXXXXXXXXXXX`
5. Add the message you want to send in **Payload**. See the example below.\
   alert.alerts

   ```
   {
     "text": "There is an alert {{alert.monitor.name}} that is affecting the digital experience"
   }
   ```
6. **Send Test** to make sure the message is pushed into Slack.

{% hint style="info" %}
Refer to the [Slack API ](https://api.slack.com/reference/surfaces/formatting#rich-layouts)documentation for more information about supported payloads.
{% endhint %}


---

# 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.nexthink.com/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/webhook-use-cases-setup/sending-data-to-a-slack-channel.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.
