All jobs

Add a Modal to a Slack Bolt App

Yes. An agent adds a modal with input blocks to your Bolt for JavaScript app, opens it from a button and a shortcut, validates the submission, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the whole app before it adds a view, which in an app laid out like slack-samples/bolt-js-getting-started-app is short. package.json is an ES module with one dependency, @slack/bolt at ^5.1.0 (the lockfile resolves 5.1.0, which pulls in Express 5 and @slack/web-api 8.1.1), and one script, start, that runs node app.js. app.js creates new App({ token: process.env.SLACK_BOT_TOKEN, socketMode: true, appToken: process.env.SLACK_APP_TOKEN }), listens with app.message('hello', ...) and replies with a section block whose accessory is a "Click Me" button with action_id: button_click, and app.action('button_click', ...) acknowledges the click and says who clicked. manifest.json grants channels:history, chat:write and im:history, subscribes to message.channels and message.im, enables interactivity and Socket Mode, and defines no slash command and no shortcut. AGENTS.md asks for no code comments and clear names, and .github/dependabot.yml checks npm weekly.

The modal needs an entry point that carries a trigger_id, and the existing button is one. The agent rewrites the button_click listener: it still calls ack() first, then calls client.views.open with body.trigger_id and a view of type: modal, a callback_id such as feedback_modal, a title of at most 24 characters, a submit button, and blocks made of an input block with a plain_text_input (multiline) for the message and an input block with a static_select for a category. The channel the button was clicked in goes into the view's private_metadata, because a view submission does not carry a channel. Slack accepts a trigger_id for three seconds, so the views.open call is the first thing after ack() and is wrapped in a try/catch that logs through app.logger.

Submissions arrive at app.view('feedback_modal', ...). The handler reads view.state.values by block_id and action_id, and when the message is blank it answers ack({ response_action: 'errors', errors: { message_block: 'Add a message' } }), which Slack shows under that input without closing the modal. A valid submission is acknowledged with a plain ack(), which closes the view, and then posted back to the channel from private_metadata with client.chat.postMessage, mentioning the submitter from body.user.id. The existing chat:write scope covers that call, so manifest.json gains nothing for it.

For a second entry point that does not depend on someone saying "hello", the agent adds a global shortcut: a shortcuts entry under features in manifest.json with type: global, a callback_id of open_feedback and a name, and an app.shortcut('open_feedback', ...) listener that opens the same view. Because a shortcut has no channel, that path leaves private_metadata empty and the submission handler falls back to a direct message to the submitter. The sandbox has no Slack tokens, so the agent proves what it can without a workspace: node --check app.js, a start with placeholder tokens that fails at authentication and nowhere earlier, and the view payload checked by hand against the limits it knows (the title length, one action_id per block, input blocks only inside a modal).

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add a modal to this Bolt for JavaScript app. Read package.json, package-lock.json, app.js, manifest.json and AGENTS.md first. Change the button_click action listener to open a modal with client.views.open and body.trigger_id after ack(): callback_id feedback_modal, a multiline plain_text_input and a static_select inside input blocks, a submit button, and the channel id in private_metadata. Add an app.view listener for feedback_modal that returns response_action errors for a blank message, otherwise acknowledges and posts the submission to the channel from private_metadata with chat.postMessage. Add a global shortcut with callback_id open_feedback in manifest.json and an app.shortcut listener that opens the same view, falling back to a direct message when there is no channel. Keep the AGENTS.md style: no code comments. Run node --check app.js and start the app with placeholder tokens to show it fails only at authentication, and open a pull request that lists every manifest change the reader must re-apply in the app settings.",
  "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

The pull request changes app.js and manifest.json and nothing else: the dependency list is already enough. Its description shows the view payload, explains the private_metadata round trip, lists the one manifest change (the global shortcut) that the reader must apply in the app's settings page or by re-importing the manifest, and quotes the node --check output and the authentication error from the placeholder start.

A reviewer installs the app in a test workspace, runs npm start with real tokens, says "hello", clicks the button and submits the form once empty and once filled, then triggers the shortcut from the composer's shortcut menu. The four paths the reviewer walks are the four listeners in the diff, so the review takes minutes.

From then on the app has a form, and the next field is one more input block in the view and one more read in the submission handler.

Run it on every Slack app repository

A team that keeps several Bolt apps sends this body once per repository from its own server, each POST /o/{org}/sessions with that repository in resources and a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own app: one that already handles a slash command gets the modal opened from that command, and one on the HTTP receiver instead of Socket Mode gets the same view with no change to how it is served.

An automation on the Project with a github trigger on pull_request.opened and the prompt "if this pull request adds or changes a view payload, check every block against Slack's limits and that each input has a matching read in the view listener, and post a review" runs once per pull request. The trigger adds the pull request after the prompt and fills in nothing else. Only work by an owner, member or collaborator fires it.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

Modal bugs are quiet: a trigger_id used a second too late, a block_id that does not match the read in the submission handler, or a title one character too long each fail at runtime with an error the app only sees in a log. The agent writes the view and the handler together, checks the payload against the limits, runs the syntax and start checks in its own sandbox, and keeps every command with the pull request, so the reviewer's first click in the test workspace is not the first time the view has been looked at.

A reviewer reads two listeners and a manifest entry rather than Slack's view reference. A team with several apps starts the same request across all of them at once.

Frequently asked questions

Does the manifest change need anything from me?

The global shortcut does. manifest.json in the repository is a copy of the app's configuration, not the source Slack reads, so after merging the reader pastes the updated manifest into the app's settings or adds the shortcut there by hand. The button path needs no manifest change because interactivity is already enabled.

Why put the channel in private_metadata?

A view_submission payload tells the app who submitted and what, but not where the modal was opened from. The agent stores the channel id when it opens the view and reads it back on submission; when the view came from a shortcut, there is no channel and the handler sends a direct message instead.

Can the modal have more than one screen?

Yes. A submission handler can answer ack with a response_action of update and a new view instead of closing. The agent builds a single screen here and names the update path in the pull request so a second screen is a small follow-up.

Why can't the agent click through the modal itself?

Opening a view needs a bot token, an app-level token and a workspace, none of which are in the repository or the sandbox. The agent proves the syntax, the start-up path and the payload shape, and leaves the click-through to the reviewer's test workspace, which the pull request describes step by step.

More Slack Bolt jobs

The same job on other stacks

More jobs like this: Hand off a long task

Keep reading