# How to configure Slack Bot

Integrating Slack with Mindflow allows you to receive notifications, share updates, and trigger actions directly within your Slack workspace, improving collaboration and efficiency.

Before you start, make sure you:

- Have an **active Slack account**.
- Have **admin access** to your Slack workspace (or request permission from your admin).
- Are logged into your **Mindflow account**.

## 1. Create a Slack app

1. Go to the Slack Developer portal: [https://api.slack.com/apps](https://api.slack.com/apps).
2. Click on **Create new app**.
   - Choose **From scratch**.
   - Give it a name (e.g., _Mindflow_).
   - Select your workspace.

   <div class="docs-screenshot-compact">

   ![Select your workspace](./assets/select-your-workspace.png)

   </div>

👉 At this stage, you have a “_blank_” app. You still need to assign permissions and generate a token.

## 2. Configure permissions (OAuth & Scopes)

Slack uses **scopes** (specific permissions).

:::note
Common examples:

- **Read messages** → `channels:history`, `groups:history`, `im:history`
- **Post messages** → `chat:write`
- **Access channel info** → `channels:read`, `groups:read`
- **Access user info** → `users:read`

:::

To add them:

1. On your app page, go to **OAuth & Permissions**.
2. Scroll down to **Scopes** → add the required scopes under **Bot Token Scopes**.

   <div class="docs-screenshot-compact">

   ![Scroll down scopes add required scopes](./assets/scroll-down-scopes-add-required-scopes.png)

   </div>

## 3. Install the app on your workspace

1. Still in **OAuth & Permissions**, click **Install App to `<Workspace>`**.
2. Accept the permissions.

👉 You will return to the OAuth page. There you will see:

- **Bot User OAuth Token** → starts with `xoxb-...` → this is the API key to paste in Mindflow.
- **User OAuth Token** → `xoxp-...`, used in some cases to act “as a user.”

You can now copy the **`Bot User OAuth Token`** to this same tab.

   <div class="docs-screenshot-compact">

![User oauth token](./assets/user-oauth-token.png)

   </div>

## 4. Add the credentials in Mindflow

Reference: [Slack Web API Authentication](https://docs.slack.dev/apis/web-api/#authentication).

1. Copy your **Bot User OAuth Token** (`xoxb-…`).
2. In your environment, create a credential for **Slack Web**.
3. Set **Credential type** to **HTTP Bearer Token**.
4. Paste the raw bot token into the **Token** field (do not add a `Bearer` prefix).

   <div class="docs-screenshot-compact">

   ![Create Slack HTTP Bearer Token credential](./assets/create-slack-bearer-token-credential.png)

   </div>

Mindflow stores the token securely and sends `Authorization: Bearer …` on requests automatically — you do not need to configure headers.

---

Now that we have our Bot installed and have established authentication, let's shift our focus to triggers. Slack provides the option to create slash commands that trigger webhooks. Let's learn how to create a command that triggers a straightforward reply in a public channel.

## Build your flow

1. Go to the **`Slash commands`** tab and click on **`Create New Command`**

   <div class="docs-screenshot-compact">

   ![Go slash commands tab click create](./assets/go-slash-commands-tab-click-create.png)

   </div>

2. Before filling in the required command fields, go to the flow you wish to trigger with the command, choose the **`Trigger`**in the \*\*\*\*Trigger tab and copy the URL of `Asynchronous`.

   <div class="docs-screenshot-compact">

   ![Before filling required command fields go](./assets/before-filling-required-command-fields-go.png)

   </div>

3. Fill in the required fields, paste the webhook in the **`Request URL`** field and click on the **`Save`** button.

   <div class="docs-screenshot-compact">

   ![Fill required fields paste webhook request](./assets/fill-required-fields-paste-webhook-request.png)

   </div>

4. Now go back to your target flow, access the steps menu and add Slack's **`Sends a message to a channel`** action.

   <div class="docs-screenshot-compact">

   ![Now go back your target flow](./assets/now-go-back-your-target-flow.png)

   </div>

5. Go to your Slack space, right-click on the channel where you want the bot to respond, select **`Show channel information`** and copy the **`Channel ID`**

   <div class="docs-screenshot-compact">

   ![Go your slack space right click](./assets/go-your-slack-space-right-click.jpg)

   </div>

6. We're now going to write the message that the bot will send in response to our slash command. Go to _**app.slack.com/block-kit-builder/**_ and click on **`Templates`**.

   <div class="docs-screenshot-compact">

   ![Were now going write message bot](./assets/were-now-going-write-message-bot.png)

   </div>

7. Select the first template by clicking on **`Use Message Template`** and copy the configuration in square brackets.

   <div class="docs-screenshot-compact">

   ![Select first template clicking use message](./assets/select-first-template-clicking-use-message.png)

   </div>

8. Go back to your flow and paste your Slack channel id in the **`Channels`** field and the message configuration in the **`Blocks`** field.

   <div class="docs-screenshot-compact">

   ![Go back your flow paste your](./assets/go-back-your-flow-paste-your.png)

   </div>

You've now set up your flow and your Slack order. Now it's time to test and deploy your flow!

## Test and run it

1. Go to your Slack channel and write **`/test`**

   <div class="docs-screenshot-compact">

   ![Go your slack channel write test](./assets/go-your-slack-channel-write-test.png)

   </div>

2. Congratulations, your flow has worked successfully and sent you the template message you set up.

   <div class="docs-screenshot-compact">

   ![Congratulations your flow has worked](./assets/congratulations-your-flow-has-worked.png)

   </div>
