# Add a Slash Command With a Modal to a Slack Bolt App

Yes. An agent adds a slash command to your Bolt for JavaScript app that opens a modal and posts the answers, updates the manifest, tests it, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-slash-command/slack-bolt/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the app and its manifest before it adds a command, because a slash command is half code and half Slack configuration. In an app like slack-samples/bolt-js-getting-started-app, `app.js` builds an `App` with `token: process.env.SLACK_BOT_TOKEN`, `socketMode: true` and `appToken: process.env.SLACK_APP_TOKEN`, registers `app.message('hello', …)`, which replies with a `section` block and a button whose `action_id` is `button_click`, and `app.action('button_click', …)`, which awaits `ack()` and then `say`; an async IIFE calls `app.start(process.env.PORT || 3000)`. `package.json` is `type: module` with `@slack/bolt` at `^5.1.0`, a `start` script and nothing else. `manifest.json` grants the bot `channels:history`, `chat:write` and `im:history`, subscribes to `message.channels` and `message.im`, enables interactivity and `socket_mode_enabled`, and has no `slash_commands` entry. `AGENTS.md` asks for no code comments and for the reason for a change to go in the pull request description, which the agent follows.

The command the prompt names, `/standup`, is added to `manifest.json` under `features.slash_commands` with `command`, `description`, `usage_hint` and `should_escape: false`, and no `url`: the field is optional in the manifest reference, and with Socket Mode on, the payload arrives over the app-level connection rather than at a request URL. `commands` joins the bot scopes, and the README gains the note from Slack's manifest documentation that adding a scope takes effect for an existing install only after the workspace reinstalls the app. In `app.js`, `app.command('/standup', …)` awaits `ack()` first, because Slack shows the user an `operation_timeout` error if nothing acknowledges within three seconds, then calls `client.views.open` with `body.trigger_id` and a modal whose `callback_id` is `standup_submit`, whose `private_metadata` carries `body.channel_id`, and whose blocks are three `plain_text_input` elements with fixed `block_id` and `action_id` values for yesterday, today and blockers.

The submission handler is `app.view('standup_submit', …)`: it awaits `ack()`, reads each answer from `view.state.values[block_id][action_id].value`, builds a message with a `header` block and one `section` per answer plus a plain `text` fallback, and posts it with `client.chat.postMessage` to the channel in `view.private_metadata`, naming the user as `<@${body.user.id}>`. Posting into a channel the bot is not a member of fails with `not_in_channel`, so the handler catches that error and sends the user a direct message explaining that the bot must be invited; any other error is logged with `logger.error`. The listeners move into `listeners/standup.js` as named exported functions, with `app.js` registering them, so they can be called without a Slack connection.

Tests use `node:test`, which the repository's Node version supports without a new dependency, in `test/standup.test.js`: the command listener is called with a fake `ack` and a `client.views.open` stub and the test asserts `ack` was awaited before `views.open`, that the `trigger_id` was passed through and the `callback_id` and `private_metadata` are set; the view listener is called with a `view.state.values` fixture and a `client.chat.postMessage` stub, asserting the channel, the fallback text and the three sections, and once more with a stub that rejects with `not_in_channel` to see the direct message path. `package.json` gains a `test` script. `app.start` needs real tokens, so the agent does not boot the app; it parses the manifest to confirm it is valid JSON with the new command and scope, and says in the pull request that the first real `/standup` is the reviewer's to run.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a /standup slash command to this Bolt for JavaScript app. Read app.js, manifest.json, package.json, README.md and AGENTS.md first. Add the command to manifest.json under features.slash_commands with a description and usage hint and no url since the app uses Socket Mode, add the commands bot scope, and note in the README that the app must be reinstalled for the new scope. In app.js register app.command('/standup') that acks first, then opens a modal with client.views.open using body.trigger_id, callback_id standup_submit, private_metadata set to the channel id, and three plain_text_input blocks for yesterday, today and blockers. Register app.view('standup_submit') that acks, reads view.state.values, and posts a header plus three sections to the channel with chat.postMessage, naming the user; on not_in_channel, DM the user that the bot must be invited. Move the listeners into listeners/standup.js as exported functions with no code comments, per AGENTS.md. Add node:test tests with stubbed ack and client for both listeners including the not_in_channel path, add a test script, run npm test, include the output, and open a pull request whose description gives the reasons.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that adds `listeners/standup.js` and `test/standup.test.js`, and changes `app.js`, `manifest.json`, `package.json` and `README.md`. The `hello` message listener and the `button_click` action are unchanged, and no dependency is added.

The description carries the reasons `AGENTS.md` keeps out of the code: why `ack` comes first, why the channel id rides in `private_metadata`, why there is no `url` in the manifest, and the `not_in_channel` handling, with the `node --test` output quoted. The commands and their full output are in the transcript at `GET /o/{org}/sessions/{id}/messages`.

Before merging, a reviewer pastes the updated `manifest.json` into the app's settings, reinstalls the app to the workspace, starts it with the two tokens, invites the bot to a channel and runs `/standup` there. A follow-up message to the same session can add a date picker, post to a fixed channel instead of the invoking one, or store the answers before posting.

## Run it on every Bolt app that needs one more command

A team with several Slack apps sends one `POST /o/{org}/sessions` per repository with this prompt as `input`, the command name changed per app, and the repository in `resources`. Each run reads its own `manifest.json` and `app.js`, so an app on HTTP mode gets a `url` in the manifest entry pointing at its request URL with `/slack/events` appended, and one that already splits listeners into files gets the new one in that layout.

Send a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run it already started. The key's `webhook_url` reports when each run the key starts finishes, with `session_url` for the pull request link and the test output.

## Why run it on Rush?

A slash command fails in ways the code never shows: a missing scope, a manifest that still needs a reinstall, an `ack` that comes after a slow call, a channel the bot was never invited to. The agent reads the manifest and the app together, writes both halves, and proves the listener logic with stubbed Slack clients in a sandbox of its own, with the output kept.

The pull request carries the manifest change, the listeners and the tests, so a reviewer's first `/standup` is a confirmation rather than a debugging session. Several apps can be done at once, each in its own sandbox with its own pull request.

## Frequently asked questions

### Why is there no url in the manifest entry?

The app runs in Socket Mode, so Slack delivers the command over the app-level websocket and the `url` field, which the manifest reference marks optional, is not needed. An app on HTTP mode needs the request URL with `/slack/events` appended, and the agent writes it when it finds `socketMode` off.

### Do I have to reinstall the app?

Yes, once. The `commands` scope is new, and Slack's manifest documentation says scope additions reach an existing install only after the workspace reinstalls the app. The README gains that step next to the manifest instructions.

### What if the bot is not in the channel?

`chat.postMessage` fails with `not_in_channel`. The view handler catches it and sends the user a direct message saying the bot must be invited with `/invite`, so the standup is not lost silently; the test suite covers that path with a rejecting stub.

### Can the agent test it without a Slack workspace?

The listener logic, yes: the tests call the exported functions with stubbed `ack`, `views.open` and `chat.postMessage` and check what they are called with. Opening a real modal needs the tokens and an installed app, which the pull request leaves to the reviewer and says so.

### Could the command take its text inline instead of a modal?

Yes. The command payload carries `command.text`, so `/standup did x; doing y; blocked on z` could be parsed without a modal. The modal gives three labelled fields and validation; say which you prefer and the agent writes that version.

## More Slack Bolt jobs

- [Add Structured Logging to a Slack Bolt App](https://getrush.ai/run/add-structured-logging/slack-bolt/)
- [Convert a Bolt for JavaScript Slack App to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/slack-bolt/)
- [Dockerize a Slack Bolt App](https://getrush.ai/run/dockerize-app/slack-bolt/)

## The same job on other stacks

- [Add a Slash Command to a discord.js Bot](https://getrush.ai/run/add-slash-command/discord-js/)
- [Add Slash Commands to a discord.py Bot](https://getrush.ai/run/add-slash-command/discord-py/)

## More jobs like this: Hand off a long task

- [Add Slim CI for a dbt Project With GitHub Actions](https://getrush.ai/run/add-slim-ci/dbt/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
