# Node Slack bot

A Slack standup bot posts team updates, explains its commands when mentioned, and reports how long its current connection has been open. Tokay keeps it connected as one Background Worker.

This project fits a workplace bot that listens over Slack Socket Mode instead of exposing a public endpoint. Tokay runs the long lived process and keeps the connection logs close to its Secrets.

## Facts

- Runtime: Node.js
- Framework: Slack Bolt
- Service types: Background Worker
- Resources: None
- Required secrets: `SLACK_BOT_TOKEN`, `SLACK_APP_TOKEN`

## What it does

Mention the bot in a channel and it replies in a thread with a short guide to its two commands.

Enter `/standup` followed by an update and the bot posts it to the channel under your Slack identity. An empty update stays private and asks you to add one useful line.

Use `/botuptime` for a private response showing the age of the current Socket Mode connection.

## Deploy it

Bring this folder to Tokay any way you like. Paste or upload it in the dashboard, push it with git, or hand it to your AI agent along with [our agent instructions](https://app.tokay.io/llms.txt). Tokay figures out the rest.

Working in Claude, ChatGPT, VS Code, or another MCP client? Connect the [Tokay MCP server](https://tokay.io/docs/platform-mcp) and ask your agent to deploy this example. It signs in through your browser, so there is no token to paste.

New to Tokay? The [getting started guide](https://tokay.io/getting-started) walks you through your first deploy.

## Create the Slack app

Create and install the Slack app before deploying the bot. This usually takes about two minutes.

1. Open [Your Apps](https://api.slack.com/apps) and choose **Create New App**.
2. Choose **From an app manifest**, select your workspace, and paste this repository's `manifest.json` into the JSON editor.
3. Choose **Next**, review the permissions, then choose **Create**.
4. Open **Install App** and choose **Install to Workspace**, then **Allow**.
5. Copy the **Bot User OAuth Token** that begins with `xoxb`. Keep it ready for `SLACK_BOT_TOKEN` in the deployment steps below.
6. Open **Basic Information**. Under **App-Level Tokens**, choose **Generate Token and Scopes**.
7. Name the token, add the `connections:write` scope, and choose **Generate**.
8. Copy the token that begins with `xapp`. Keep it ready for `SLACK_APP_TOKEN` in the deployment steps below.

Keep both tokens out of this folder and out of chat.

## Add the Slack tokens

Open **Environment** and find `SLACK_BOT_TOKEN` and `SLACK_APP_TOKEN` under **From your code**. Choose **Set shared value** for each one, paste the matching token, and save it.

When both rows say **Good to go**, follow the deployment tracker and choose **Go Live** if that action appears. The Background Worker has no public page. **Logs** will show when the bot is connected.

## Try it

1. Invite `@Standup Pocket` to a test channel and mention it for help.
2. Enter `/standup Shipped the export flow and reviewing production logs next`.
3. Run `/botuptime`, restart the Worker, then run it again. The shorter age proves the new process reconnected.

## What failure looks like

A missing token keeps the bot from going live. If a token is present but wrong, **Logs** shows a direct Slack connection error.

Tokay restarts the Background Worker and makes a repeated failure visible as an incident. Replace the invalid Project Secret and the bot will reconnect.

## How it works

You can use the bot without a public URL because Bolt keeps one outbound WebSocket open to Slack. Mentions and slash commands arrive on that connection, and replies go back through Slack's API.

During a deployment, Tokay gives the old process time to close its connection before the replacement takes over. A failed login remains in **Logs** instead of looking like a silent bot.

## Secrets

| Name | Required | Purpose |
| --- | --- | --- |
| `SLACK_BOT_TOKEN` | Yes | Gives the installed bot its workspace permissions. |
| `SLACK_APP_TOKEN` | Yes | Opens Socket Mode with `connections:write`. |

## Grow from here

Try the [Discord bot](/examples/node-discord-bot) when the conversation happens in a community server instead.

## Source files

- [app.js](https://tokay.io/examples/src/node-slack-bot/app.js)
- [manifest.json](https://tokay.io/examples/src/node-slack-bot/manifest.json)
- [package.json](https://tokay.io/examples/src/node-slack-bot/package.json)

## Download and source

- [Download the complete project](https://tokay.io/examples/downloads/node-slack-bot.zip)
- Last updated: 2026-07-31
- Example revision: `52c7b7f`
- [View this revision on GitHub](https://github.com/tokayio/tokay-examples/tree/52c7b7ffd52e157375b08f1f11ff4fbe6c498642/node-slack-bot)
- [Host a Slack bot](https://tokay.io/use-cases/host-slack-bot)
