> ## Documentation Index
> Fetch the complete documentation index at: https://help.nextmatter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate with Slack

> Send customized Slack messages directly from a Next Matter workflow to dedicated channels.

## Before you begin

<Tip>
  Check out our ready-made templates available when you add a step and select **Templates > 3rd party templates**. You can use the templates to create a set of pre-configured steps. Need a specific template? Click the **Contact us** button in the top right of the page and let us know.
</Tip>

## Create a Next Matter Bot in your Slack workspace

The bot should be authorized to send messages on behalf of Next Matter.

1. Go to [https://api.slack.com/apps?new\_app=1](https://api.slack.com/apps?new_app=1). You might have to log in.
2. Click **Create an App** and choose **From scratch**.
3. Enter the app's name. It might be "Next Matter Bot".
4. Select your workspace from the dropdown.
5. Click **Create App**.
6. In the **Display Information** section you can set the App's logo. Use the Next Matter logo for the bot.
7. In the **Add features and functionality** section, click **Bots**.
8. Click **Review Scopes to Add**.
9. Scroll down to **Scopes**. In the **Bot Token Scopes**, click **Add and OAuth Scope**.
10. Add scopes one by one by selecting them from the dropdown. You need the following scopes:
    * "channels:read"
    * "channels:join"
    * "chat:write"
    * "chat:write.public"
    * "users:read.email"
11. Scroll up to **OAuth Tokens for Your Workspace** and click **Install to Workspace**.
12. Click **Allow**.
13. Copy and save the displayed token.

### Get the channel ID

<Info>
  If you don't have channels yet, create one in Slack.
</Info>

1. Go to [https://api.slack.com/methods/conversations.list/test](https://api.slack.com/methods/conversations.list/test).
2. In the **Arguments** section, paste the token in the **Or, provide your own token field**.
3. Click **Test Method**.
4. In the API response section, search for the name of the channel to place the bot. The ID of the channel will be in the line above the name. For example:

<CodeGroup>
  ```json JSON theme={null}
  {"id": "CAQKA5GAW",
              "name": "CHANNEL_NAME",
              "is_channel": true,
              "is_group": false,
              "is_im": false
  }
  ```
</CodeGroup>

### Add bot to channel

1. Open your Slack app and select the channel to post messages.
2. Click the gear icon in the top right corner of the channel.
3. Click **Add an App**.
4. Type "Next Matter" in the search bar.
5. Click **Add**.

You should see a message in the channel that the bot has been added.

### Configure the notification step in a process

1. In your Next Matter portal, click **Workflows**, and then click the workflow you want to send messages to Slack.
2. Click **Edit workflow**.
3. Click **+Add step** and select **Integration > Custom integration**.
4. Click **Settings** to configure the step.
5. Enter the following details:

   <CodeGroup>
     ```json JSON theme={null}
     {
      "channel": "C04TYPWLF2Q",
     "text": "This is a line of text.\nAnd this is another one.\n\nThis is unquoted text\n>This is a sentence with some `inline *code*` in it.\n<{1. Enter all test details - URL - URL (plain)}" //this is a placeholder to replace
     }
     ```
   </CodeGroup>

   * **Method**: POST
   * **URL**:
   * **Headers**: Content-Type: application/json
   * **Headers**: Authorization: `Bearer BOT_TOKEN`. Your entered details might look like the following: `Bearer xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`
   * In the **Body** enter the values. For example, the body might look like the following.
6. Save your changes.

## Send a message to a user

As part of the workflow, you might want to send a Slack message to a specific user. The message will come from the customer’s Slack Next Matter App (see [Create a Next Matter bot](#create-a-next-matter-bot-in-your-slack-workspace)).

To send the message, you'll need an integration step to get the Slack user ID and a step to send the message to the owner of this ID.

<Info>
  You'll need a Slack token to authorize your calls. For more on getting the token, see [Slack documentation](https://api.slack.com/tutorials/tracks/getting-a-token). The API token might look like the following: `xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`.
</Info>

1. Click **+Add step** and select **Integration > Custom integration**.
2. Click **Settings** to configure the step.
3. Enter the following details:
   * **Method**: GET
   * **URL**:
   * **Headers**: Authorization: `Bearer BOT_TOKEN`. Your entered details might look like the following: `Bearer xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`
   * **Body type**: Form data
4. Create a variable for the user ID with the value of `$.user.id`.
5. Save your changes.
6. Now create a step to send the message. Again, click **+Add step** and select **Integration > Custom integration**.
7. Click **Settings** to configure the step.
8. Enter the following details:

   <CodeGroup>
     ```json JSON theme={null}
     {
      "channel": "CHANNEL_ID",
     "text": "This is a line of text.\nAnd this is another one.\n\nThis is unquoted text\n>This is a sentence with some `inline *code*` in it.\n<{1. Enter all test details - URL - URL (plain)}"//this is a placeholder
     }
     ```
   </CodeGroup>

   * **Method**: POST

   * **URL**:

   * **Headers**: Content-Type: application/json; charset=utf-8

   * **Headers**: Authorization: `Bearer BOT_TOKEN`. Your entered details might look like the following: `Bearer xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`

   * In the **Body** enter the values. For example, the body might look like the following. To get the channel ID, see [Get the Slack channel ID](/docs/integrate-with-slack#get-the-channel-id).

   9. Save your changes.

## Create a channel and invite users

<Info>
  You'll need a Slack token to authorize your calls. For more on getting the token, see [Slack documentation](https://api.slack.com/tutorials/tracks/getting-a-token). The API token might look like the following: `xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`.
</Info>

1. Click **+Add step** and select **Integration > Custom integration**.
2. Click **Settings** to configure the step.
3. Enter the following details:
   * **Method**: POST
   * **URL**:
   * **Headers**: Authorization: `Bearer BOT_TOKEN`. Your entered details might look like the following: `Bearer xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`
   * **Content type**: application/json; charset=utf-8
   * **Body**:

     <CodeGroup>
       ```json JSON theme={null}
       {
       "name":"CHANNEL_NAME_WITHOUT_#" //replace the placeholder with your data
       }
       ```
     </CodeGroup>
4. Create a variable for the channel ID with the value of `$.channel.id`.
5. Save your changes.
6. To invite users to your channel, click **+Add step** and select **Integration > Custom integration**.
7. Click **Settings** to configure the step.
8. Enter the following details:
   * **Method**: POST
   * **URL**:
   * **Headers**: Authorization: `Bearer BOT_TOKEN`. Your entered details might look like the following: `Bearer xoxb-364112219665-5014650446325-Pt0U8RutXz1FEwVLQpkj54lf`
   * **Content type**: application/json; charset=utf-8
   * **Body**:

     <CodeGroup>
       ```json JSON theme={null}
       {
         "channel": "{2. Create Slack Channel - Integration step - channel_id (plain)}",//this is data reference
         "users":["EMAIL_1", "EMAIL_2"]//enter the email addresses of the users to invite
       }
       ```
     </CodeGroup>
9. Create a variable for the channel ID with the value of `$.channel.id`.
10. Save your changes.

## Send a reminder

### Before you begin

* You'll need to enter your Slack Team ID in the body of the send reminder call. To get the ID:
  1. Open any web browser and log in to your Slack account.
  2. Go to your workspace main page and check the URL in the search bar at the top.
  3. Copy the Team ID from the URL

<Frame>
  <img src="https://mintcdn.com/nextmatter/n_eDywRY2Y_RWlpG/images/docs/a9a754f-id.png?fit=max&auto=format&n=n_eDywRY2Y_RWlpG&q=85&s=fd7e35dd86e3534007b346cab14ffa35" alt="Image of the Team ID in the Slack URL" width="367" height="37" data-path="images/docs/a9a754f-id.png" />
</Frame>

* You'll need a Slack token to authorize your calls. For more on how to get the token, see [Slack documentation](https://api.slack.com/tutorials/tracks/getting-a-token).

### Set up reminder

1. Click **+Add step** and select **Integration > Custom integration**.
2. Click **Settings** to configure the step.
3. Enter the following details:
   * **Method**: POST
   * **URL**: `URL: `
   * **Headers**: Content-Type: application/json; charset=utf-8
   * **Headers**: Authorization: Slack\_API\_Key
   * **Body**:

     <CodeGroup>
       ```json JSON theme={null}
       {
       		"text": "REPLACE_WITH_REMINDER_TEXT",
       		"time": "REPLACE_WITH_REMINDER_FREQUENCY", //for example, every weekday at 9:45am
            "team_id": "REPLACE_WITH_TEAM_ID"
       }
       ```
     </CodeGroup>
4. Create a variable for the Slack reminder ID with the value of **\$reminder.id**.
5. Save your changes.

### Stop the reminder

1. Click **+ Add step** and select **Integration > Custom integration**.
2. Click **Settings** to configure the step.
3. Enter the following details:
   * **Method**: POST
   * **URL**: [https://slack.com/api/reminders.delete](https://slack.com/api/reminders.delete)
   * **Headers**: Content-Type: application/json; charset=utf-8
   * **Headers**: Authorization: Slack\_API\_Key
   * **Body**:

     <CodeGroup>
       ```json JSON theme={null}
       {
       "reminder": "REPLACE_WITH_REMINDER_ID" //for example, Rm23456789; you can use data reference to the variable created when you set up the reminder

       ```
     </CodeGroup>
4. Create a variable for the Slack reminder ID with the value of **\$reminder.id**.
5. Save your changes.
