---
title: Configuring a Slack Route
description: A guide to creating Notehub routes to sync data with Slack using Blues Notecard over Cellular, Satellite, LoRa, or WiFi connectivity.
source_url: https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route/
canonical_url: https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route/
markdown_url: https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route.md
---

# Configuring a Slack Route

Notehub allows you to route data to [Slack](https://slack.com/), making it easy to send chat messages for some or all of your events. Let's look at how it works.

> **Note:**
>
> To route events to Slack you must have admin access to a Slack channel, and have created a Slack app. If you haven't built a Slack app before, you can start a new one [here](https://api.slack.com/apps/new).

## Configuring the Route

To create a Slack route, open your Notehub project, head to the **Routes** tab, click the **Create Route** button, and then find the Slack option. Click **Select** to get started.

![Slack route option](https://dev.blues.io/images/notehub/slack/route-option.png?v=a8621e06)

On the next screen you'll be asked to provide a variety of values to configure your route.

1. The **Route name** controls the name of your route within Notehub.

2. The **Slack Route Type** lets you choose between two different ways to interact with the Slack API.

   - (Recommended) A type of **Webhook** is the easiest way to interact with Slack. If you choose this option you'll create a webhook URL that can post to a single Slack channel.

   - A type of **Bearer** uses OAuth authentication to allow your Slack app to send messages. With this option you'll need to generate an OAuth token and add permissions to your app, but you'll be able to send Slack messages to different channels.

### Webhook Routes

Complete these steps if you're using a **Slack Route Type** of **Webhook**.

1. To find your **WebhookURL**, select your Slack app on [api.slack.com/apps](https://api.slack.com/apps), select **Incoming Webhooks** in the menu, and enable the **Activate Incoming Webhooks** switch.

2. After you activate incoming webhooks, scroll down the same page and find the **Add New Webhook to Workspace** button. Click that button and complete the subsequent steps to generate a Webhook URL. Copy that URL and paste it in the **WebhookURL** on your Notehub route.

   ![Webhook URL location](https://dev.blues.io/images/notehub/slack/webhook-url.png?v=627b2375)

3. [Skip ahead to these instructions](#all-route-types).

### Bearer Routes

Complete these steps if you're using a **Slack Route Type** of **Bearer**.

1. Provide the **Channel** ID you would like to send your messages to. The easiest way to get your channel ID is to right click on a channel within Slack, select **Copy**, and then **Copy Link**. The channel is in the URL you just copied, and is in the format `CXXXXXXXXXX`.

   ![Slack Channel ID location](https://dev.blues.io/images/notehub/slack/channel-id.png?v=0bde65e2)

2. To generate a **Bearer Token**, select your [Slack app](https://api.slack.com/apps) and click the **OAuth & Permissions** menu. Scroll down and find the **OAuth Tokens for Your Workspace** heading. Click the **Install to Workspace** button and complete the subsequent steps. When you're done use the **Copy** button to get the token you need for your Notehub route.

   ![OAuth token location](https://dev.blues.io/images/notehub/slack/oauth-token-location.png?v=2b5f72ea)

In order to successfully use your token to post to a channel you'll need to complete a few additional steps.

1. While still on the same **OAuth & Permissions** settings page, scroll down to the **Scopes** section, click the **Add an OAuth Scope** button, and add the `chat:write` permission. You'll likely be prompted to restart your app for the permission change to take effect.

2. In your Slack client, you need to invite your app to every channel you intend to send messages to. The easiest way to do this is with the `/invite` command.

   ![Inviting an app to Slack](https://dev.blues.io/images/notehub/slack/app-invite.png?v=675e2abf)

   > **Note:**
   >
   > Bearer routes post messages using Slack's `chat.postMessage` API, which only delivers to channels the app is a member of. If you skip this invite step, messages will fail to post even when the token and channel ID are correct.

### All Route Types

1. For **Message Type** you can select either **Text** or **Blocks**. Selecting **Text** allows you to provide simple strings. Use **Blocks** if you need to generate richer Slack messages, and use the [Slack Block Kit Builder](https://app.slack.com/block-kit-builder/#) to generate the syntax you need.

   > **Note:**
   >
   > - For the **Blocks** field you can paste either the entire JSON payload produced by the Block Kit Builder (the object that contains a top-level `"blocks"` key) or just the value of the `blocks` array itself—Notehub accepts both forms.
   >
   > - You can use [placeholder variables](https://dev.blues.io/notehub/notehub-walkthrough.md#using-placeholder-variable-substitution-interpolation) to include event-specific information in your messages. If you're building a Slack route for the first time, try using `[.body]` as **Text**, as it sends your Note's `body` as your message.

2. Scroll to the **Filters** section, set the **Notefiles** dropdown to **Selected Notefiles**, and select the Notefile you want to use this route for.

   ![route filters](https://dev.blues.io/images/notehub/edge-impulse/route-filters.png?v=ee773186)

3. When you're all set, click the **Create Route** button to save your new route.

## Testing the Route

With the route created you're now ready to test it out. The easiest way to make sure everything is working is by sending a Note using the Notecard's In-Browser Terminal.

1. Use the In-Browser Terminal to connect to your Notecard via USB. (If you're unsure how to do this check out the [Notecard quickstart](https://dev.blues.io/quickstart/notecard-quickstart.md).)

   ![Notehub.io: Web Console Button](https://dev.blues.io/images/guides/route-guides/notecard-web-console-button.png?v=25006268)

2. Once connected, associate your Notecard with a Notehub project (if it isn't already).

   ```json
   {
     "req": "hub.set",
     "product": "com.example.yourname:yourproject"
   }
   ```

3. Next, run the command below to queue a Note onto the `data.qo` Notefile. You may wish to change the `file` and `body` of your command, depending on how you configured your route.

   ```json
   {
     "req": "note.add",
     "file": "data.qo",
     "body": {
       "temp": 22
     }
   }
   ```

4. Finally, run the `hub.sync` request to send this data to your Notehub project.

   ```json
   {
     "req": "hub.sync"
   }
   ```

When the data reaches your Notehub project, Notehub will automatically route your sensor data to Slack. And if all goes well, you should see your message appear in your channel. For example, if you use a **Text** of `[.body]`, you should see a message that looks like this.

![Data within Slack](https://dev.blues.io/images/notehub/slack/slack-message.png?v=05549a17)

> **Tip:**
>
> To debug a route or inspect the exact request Notehub sends to your third-party service, open an event in Notehub, click **Route as cURL**, and choose the appropriate HTTP-based route. The modal shows a cURL command that reproduces the same request Notehub makes, with secrets (API keys, passwords, etc.) replaced by placeholders.
>
> ![view curl request from route](https://dev.blues.io/images/guides/route-tutorial/event-route-curl.png?v=22e6a261)
