Build a Slack Home Tab with AWS Lambda and EventBridge
A Slack App Home tab gives each user a private space inside Slack where your app can show a dashboard instead of relying on slash commands. This guide walks through the moving parts — the Slack surface, the views.publish call, the app_home_opened event, an EventBridge bus, and Lambda functions deployed with AWS SAM — and shows a small to-do list app that ties them together.
What a Slack App Home tab is
Every workspace member sees a separate copy of the App Home, visible only to that member and to your app. It appears in the sidebar's conversation list, and a user can also open it by selecting the app's name on a message. Because the surface is rendered on demand, you can put the right controls in front of someone at the moment they need them — a leave-request button, for instance, that works even for a colleague who has never used a slash command.
Slack's app toolkit, released at the end of 2019, bundled improved permission scopes, Block Kit (the UI framework), and the App Home tab. Turning the tab on means requesting the right permissions and enabling the home tab in your app's settings; you also need an installed Slack application in the workspace. Slack's own documentation covers both steps, so this build assumes they are done.
How the Home tab is rendered: views.publish and app_home_opened
Rendering happens when you hand Slack an array of Block Kit blocks through the views.publish Web API method. The tab is per-user and private, so the call needs the ID of the person viewing it, alongside the blocks and a bot token. User IDs can come from your own database or from Slack's Web API.
A just-in-time pattern is often the better fit: Slack fires the app_home_opened event whenever someone opens the tab. You receive that event through a webhook and then publish or refresh the tab for that individual. The event includes the user ID, so all you add is the new block set and a valid bot token.
Decision checklist — publish on demand or on open?
- Publish on demand when the tab content changes because of an action the user just took (for example, after a button click or modal submission).
- Publish on app_home_opened when the tab should reflect current state each time it is opened.
- In both cases, keep the bot token out of source code and pass it through configuration.
Why an EventBridge-backed Slack handler helps
Slack's response window is short: in most cases your endpoint has roughly three seconds to answer. That budget shrinks fast once you account for parsing the incoming event, running business logic, network round-trips and a cold start. A published engineering account of this pattern reported a cold start under 200ms, credited to keeping its Node.js modules small; if your own cold start runs higher, AWS Lambda Provisioned Concurrency is worth a look.
In the architecture that account describes, every Slack webhook first reached API Gateway, which invoked a separate Lambda per integration type (events, slash commands, dialogs). Each of those functions parsed the message, published it to an Amazon SNS topic, and returned 200 OK to Slack; the SNS topic then triggered the business-logic functions. The later design keeps that overall shape but moves webhook and event processing into a Serverless Application Repository (SAR) application and swaps SNS for EventBridge. EventBridge is a fully managed enterprise service bus: you publish events there and subscribe Lambda functions to one or more events matching a specific parameter — for example, a function that fires when a user opens the Home tab.
A generic webhook handler was not enough for Slack because some webhooks must answer verification requests, and Slack payloads arrive in mixed forms: some JSON, some URL-encoded, and button clicks as URL-encoded payloads containing stringified JSON. The Slack-specific SAR application exists to unpack those forms.
Prerequisites and SAM configuration
You need an active AWS account and basic familiarity with serverless and the AWS Serverless Application Model (SAM). Initialize a new SAM application with the node12.x runtime and open template.yaml.
If you use the newer sam deploy --guided command, deploy once before editing template.yaml. Then in samconfig.toml replace:
capabilities = "CAPABILITY_IAM"
with:
capabilities = "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND"
The CAPABILITY_AUTO_EXPAND capability is what allows SAR applications to be installed through SAM.
Your template.yaml then needs to:
- Tell CloudFormation (the engine behind SAM) that SAM is taking over.
- Pass two parameters: EventBusName (for example, SampleSlackEventBus) and BotToken. In production you would fetch the token from an API; for a sample, copy it from the Install App tab of your Slack app settings.
- Set global function configuration so it is not repeated per function.
- Define resources (added in the next steps).
- Define an output: the webhook URL used for the Slack integration.
With sam deploy --guided, also update parameter_overrides in samconfig.toml, for example:
parameter_overrides = "EventBusName=EVENT_BUS_NAME BotToken=xoxb-YOUR-BOT-TOKEN"
Replace EVENT_BUS_NAME with your bus name and xoxb-YOUR-BOT-TOKEN with a valid bot token.
Installing the SAR app and wiring the event bus
Add the SAR application to the Resources section of template.yaml. That snippet creates an EventBridge event bus using the name you supplied and installs the SAR application. At the time of writing the app version was 1.1.0; use the latest version from SAR or the project's GitHub releases.
Field and control map for the sample:
- EventBusName — names the EventBridge bus (SampleSlackEventBus is a reasonable choice).
- BotToken — the Slack bot token; in production, fetch it from an API rather than passing it as a parameter.
- BOT_TOKEN — the Lambda environment variable that carries the token so it is not hardcoded.
- CodeUri — points SAM at the function code (build/home-tab in the sample).
- Handler — the exported handler (lambda.handler in the sample).
- Events — the EventBridge rule that triggers the function.
Handling the Home tab opening, button clicks and modal submissions
The first event to handle is the opening of the App Home tab. Add a Lambda function named SlackHomeTab (or any descriptive name) with Type: AWS::Serverless::Function. Its Properties block sets CodeUri, Handler, the BOT_TOKEN environment variable, and the Events section that defines the trigger.
The trigger is an EventBridge event pattern: the bus invokes the function only when the event matches the expected structure. The same mechanism can target a specific slash command or a specific button click.
For a click on an Add todo button, the only change is the event pattern. Slack buttons send a payload containing actions; if one of the actions has the value add_todo, EventBridge invokes that function. Modal submission is just another event, handled the same way with its own pattern.
Worked example — the to-do list demo:
- A user opens the Home tab; app_home_opened fires, and the SlackHomeTab function publishes the to-do view.
- The user clicks Add todo; the action value add_todo matches the pattern and a second function runs.
- A modal opens for the new item; the submission arrives as another event and its handler stores the item.
- The Home tab is republished so the list reflects the new entry.
Deploying and connecting Slack
Write the function code (the sample GitHub repository has a complete version). From the repository, run npm install to install dependencies, npm run build to compile the TypeScript, and sam deploy to deploy.
The deployment outputs a webhook URL. Set that URL as the webhook URL in both the Event Subscriptions and Interactive Components sections of your Slack application settings. The result should resemble the demo recording: a Home tab that shows the to-do list and responds to the Add todo button.
Scaling and next steps
The architecture is simple, flexible and scalable. A published engineering account of this pattern reported that its setup handled up to 1000 parallel requests by default, a ceiling that can be raised through AWS support, and that billing is usage-based: if nobody uses the integration, the infrastructure costs nothing. Treat those figures as dated third-party observations and confirm current AWS limits and pricing for your own account.
A sensible next step is a database for bot tokens and user preferences; DynamoDB is a good fit because it scales automatically and suits serverless applications. From there you can add more event patterns for additional buttons, commands and modal flows.
Frequently asked questions
Do I need to call views.publish myself, or does Slack render the Home tab automatically?
You call views.publish with an array of Block Kit blocks, a bot token, and the user ID. Slack does not build the layout for you. A common pattern is to call it in response to the app_home_opened event so the tab reflects current state each time it is opened.
Why can't I reuse a generic webhook handler for Slack?
Slack webhooks are not uniform. Some must answer verification requests, some payloads are JSON, some are URL-encoded, and button clicks arrive as URL-encoded payloads containing stringified JSON. A generic handler cannot unpack all of those forms, which is why a Slack-specific SAR application is used.
What is CAPABILITY_AUTO_EXPAND for?
It lets SAM install applications from the AWS Serverless Application Repository. Without it, the deploy step cannot expand the nested SAR application in your template.
How do I trigger a function only when a specific button is clicked?
Use an EventBridge event pattern that matches the action value. Slack button payloads contain actions; if one action has the value add_todo, the pattern matches and EventBridge invokes the function. The rest of the function definition is the same as for the Home tab handler.
Where should the bot token live in production?
Not in source code. In the sample it is passed as the BotToken SAM parameter and exposed to the function as the BOT_TOKEN environment variable. In production, fetch it from an API or store it in a database such as DynamoDB, which is also the recommended place for user preferences.