How to understand a Slack app (Bolt for JavaScript) codebase
Bolt apps register listeners on an `App` instance for slash commands, events, interactive actions and modal submissions. Every interaction must be acknowledged quickly with `ack()`; the real work happens after.
How to tell it's Slack app (Bolt for JavaScript)
@slack/boltinpackage.jsonnew App({ token, signingSecret, socketMode })app.command,app.event,app.action,app.viewlisteners
Where things usually live
- src/app.ts
- Creates the app, registers listeners, starts it.
- src/listeners/
- Listeners grouped by type: commands, events, actions, views.
- src/views/ or blocks/
- Block Kit layouts for messages and modals.
- manifest.json or manifest.yml
- The app's scopes, commands and event subscriptions.
Conventions, not rules. Real projects rename and move things, so confirm against the repository.
Where to start reading
- The listener registration in
app.ts - The manifest, for scopes and subscriptions
- The
action_idandcallback_idstrings that link blocks to listeners
How a request moves through the code
- Slack delivers a request over a socket or HTTP.
- Bolt verifies it and finds the matching listener.
- The listener calls
ack()immediately. - It then does the work, often calling
client.chat.postMessageor opening a modal withclient.views.open. - A modal submission arrives as a
view_submission, handled byapp.viewwith itscallback_id.
Questions to ask about the repository
- List each command, event and action with its listener.
- Which OAuth scopes does the app use, and why?
- Which listeners do slow work after
ack()?
What trips people up
- If
ack()isn't called within about three seconds, Slack shows an error to the user even if the work succeeds. - Interactive components connect to listeners by ID strings, so search for them in both places.