---
title: "Connect Slack to an AI-built tool, with no token in the code"
url: https://while.sh/en/guides/connect-slack-ai-tool/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-18
---

# Connect Slack to a tool built with Claude or ChatGPT (2026)

Your tool built with Claude needs to alert the team in Slack: a signed quote, low stock, a request to approve. The reflex is to paste the Slack token into the code, where it ends up leaking. On while, it stays in while, and your AI never sees it. Here is how, in about ten minutes.

A tool built with Claude or ChatGPT reaches another level when it **alerts the team where it already is**, in Slack. A signed quote, stock that drops below the threshold, an expense report waiting for approval: the team sees it right away. To post, the tool needs a Slack token. That is where things often go wrong: **the token ends up pasted into the code**, then pushed to GitHub. Slack revokes it when it finds it (source 3), and the tool goes silent without telling anyone.

On while, the Slack token **stays in while**. The tool posts without ever holding it, and your AI never sees it.

> **The short version.** Create an app at api.slack.com/apps, give it the chat:write scope, install it and copy its bot token, which starts with xoxb-. Ask your AI to connect Slack, then paste the token into while through the link it gives you. The tool posts in your channels, and every call is logged.

## Webhook or bot token: which one to choose

Slack offers two ways to have a tool post, and they do not serve the same purpose.

| | Incoming webhook | Bot token |
|---|---|---|
| What it allows | Posting in a single channel | Posting in chosen channels, reading depending on scopes |
| Where the secret lives | In the webhook URL | In the token, on its own |
| What it is tied to | One channel and the person who created it | The app, whoever the person is |
| Our advice on while | For a quick test | For a team tool |

The webhook is quick: one URL, one channel (source 3). The **bot token** is more flexible, it does not depend on the person who installed it, and it stays valid when they leave the company (source 2).

## Connect Slack to your tool, in four steps

The whole thing takes about ten minutes, and you have no code to write.

1. **Create an app in Slack.** At api.slack.com/apps, click Create New App, give it a name, the one that will sign the messages, and choose your workspace (source 1).
2. **Give it the right to post.** Under OAuth & Permissions, in Bot Token Scopes, add chat:write. Add chat:write.public if the bot should post in every public channel without being added to it (source 1).
3. **Install it and copy the token.** Click Install to Workspace, then go back to OAuth & Permissions. The bot token, which starts with **xoxb-**, shows there (sources 1 and 2).
4. **Paste the token into while.** Ask your AI to connect Slack. It declares the connection and gives you a link, where you paste the token. Neither your AI nor the tool's code sees it.

For a private channel, add the bot to the channel with the `/invite @bot-name` command (source 1). If your Workspace Owners have turned on app approval, the installation in step 3 waits for their approval (source 4).

> You, to your AI: Connect Slack to this tool, and post in the #orders channel every time an order goes over $5,000.

<figure class="illus"><img src="/illustrations/slack-relais-1200.webp" srcset="/illustrations/slack-relais-768.webp 768w, /illustrations/slack-relais-1200.webp 1200w" sizes="(min-width: 48rem) 46rem, 100vw" width="1536" height="1024" loading="lazy" decoding="async" alt="A tool built with AI posts in Slack through while: the Slack bot token is added to each call inside while, out of the code, and every message sent to the team channel is logged in the history" /><figcaption>The tool posts in Slack through while, which adds the token to each call.</figcaption></figure>

## What while does on each call

The tool calls Slack **through while**, without a token. while adds the bot token to each call, and logs it in the history. For the first seven days, reads go through and teach while what the tool calls. **Posting a message** is a write: it goes through once you approve its rule. After that, an unexpected call is refused, and your AI is told.

You can also ask for your approval before a sensitive call.

> You, to your AI: Ask me before the tool posts in the #general channel.

The credentials of your software are detailed on our [security](/en/security/) page, and the same mechanism works for any API in [connect an API with no credentials in the code](/en/guides/api-keys-out-of-code/).

## Changing the token

If the token leaks or you recreate the app, Slack gives you a new one under OAuth & Permissions. **Paste it into while**: the tool uses it from the next call, without being put back in place, and your AI has nothing to redo.

## What while adds around it

- **Your colleagues** use the tool with a while account for up to 3 people, or, on the Pro plan, with their email account, Google or Microsoft. See [keep a tool for your colleagues](/en/guides/internal-tool-company-sign-in/).
- **Connected software**: one on the Libre plan, and 25 on the Pro plan, Slack included.
- **The tool's data** is backed up every day, and your tools are hosted in France by Nextmap.

For stock alerts ready to post, see [the inventory tracker with alerts](/en/guides/inventory-tracker-low-stock-alerts-ai-2026/), and for related connections, [connect HubSpot](/en/guides/connect-hubspot-ai-tool/) and [connect Google Sheets](/en/guides/connect-google-sheets-ai-tool/).

## Try it with your tool

Give this message to your AI, then ask it to connect Slack. The trial is **free, with no sign-up**, and your tool has its address **in 3 minutes**.

```text titre="The message to give your AI"
Read while.sh/agents and help me get started with while.
```

## Sources

1. [Slack, Quickstart with app settings](https://docs.slack.dev/app-management/quickstart-app-settings), 2026-11-18
2. [Slack, Tokens](https://docs.slack.dev/authentication/tokens), 2026-11-18
3. [Slack, Sending messages using incoming webhooks](https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks), 2026-11-18
4. [Slack, Manage app approval for your workspace](https://slack.com/help/articles/222386767-Manage-app-approval-for-your-workspace), 2026-11-18

## Questions

### How do you get a Slack API token?

Create an app at api.slack.com/apps, add the chat:write scope under OAuth & Permissions, then install it to your workspace. The bot token, which starts with xoxb-, then shows on the same page (source 1).

### Do you need a Slack admin to create the token?

Not by default. If the Workspace Owners have turned on app approval, the installation waits for their approval (source 4).

### Does my AI see the Slack token?

No. Your AI declares the connection to Slack and gives you a link. You paste the token into while there, and neither your AI nor the tool's code sees it.

### Why doesn't the bot post in my channel?

It is not part of the channel yet. Add it with the /invite command followed by its name, or give it the chat:write.public scope for public channels (source 1).

### Isn't an incoming webhook enough?

To post in a single channel, it is. But the webhook URL contains the secret itself, and Slack revokes it when it leaks (source 3). The bot token works across channels, and while keeps it out of the code.
