alt-text-slack-bot aims to encourage accessible image sharing in a Slack workspace. When configured and added to a workspace, this Slack bot will detect when an image file has been shared in a channel without alternative text. It will send a friendly reminder that can only be seen by the user who posted the image along with instructions on how to add the alternative text. Optionally, the bot can also generate AI-powered alt text suggestions to make it even easier for users to add accessible descriptions.
This repo contains the code for the bot setup and should be customized to fit your workspace needs. For a comprehensive guide on the process of setting up a Slack app and installing it in a workspace, check out a fantastic tutorial by @lukeocodes at DEV: Guy's Bot - Inclusive Language in Slack.
The alt text feature in Slack is relatively new and hidden so a lot of people don't know about it or forget to use it. This bot was created to ensure that images are accessible to everyone, including channel members who are blind or have low-vision. This bot eliminates the potential burden of individual members having to remind people to add alt text.
This bot is configured to deploy as a serverless function on Netlify. Follow these steps to set up and deploy:
- A Netlify account
- A Slack workspace where you have permission to install apps
- Node.js and npm installed locally (for testing)
- Go to api.slack.com/apps and click Create New App
- Choose From scratch
- Give your app a name (e.g., "Alt Text Reminder Bot") and select your workspace
- Click Create App
- In the left sidebar, go to OAuth & Permissions
- Scroll down to Scopes → Bot Token Scopes
- Add the following scopes:
channels:history- Allows the bot to read public channel historychat:write- Allows the bot to send messagesgroups:history- Allows the bot to read private channels where it has been invitedfiles:read- Allows the bot to read and download files
- Scroll up and click Install to Workspace
- Authorize the app in your workspace
- Copy the Bot User OAuth Token (starts with
xoxb-) - you'll need this for Netlify
- In the left sidebar, go to Event Subscriptions
- Toggle Enable Events to On
- You'll need to set the Request URL later (after deploying to Netlify)
- Under Subscribe to bot events, click Add Bot User Event
- Add the following events:
message.channels- This allows the bot to receive messages posted to public channelsmessage.groups- This allows the bot to receive messages posted to private channels (required for private channels to work)
- Click Save Changes
- In the left sidebar, go to Basic Information
- Under App Credentials, find Signing Secret
- Click Show and copy the value - you'll need this for Netlify
- Push your code to a Git repository (GitHub, GitLab, or Bitbucket)
- Go to app.netlify.com and sign in
- Click Add new site → Import an existing project
- Connect your Git provider and select this repository
- Configure build settings:
- Build command:
npm run dist - Publish directory: (leave empty - not needed for functions)
- Build command:
- Click Show advanced and add environment variables:
SLACK_TOKEN- Your Bot User OAuth Token (from Step 2)SLACK_SIGNING_SECRET- Your Signing Secret (from Step 4)SLACK_WORKSPACE- Workspace type:useit(default) ort12t(see Environment variables for details)ALT_TEXT_GENERATION_API_KEY- API key for the alt text generation service (optional, but required for suggestions)EXCLUDED_USER_IDS- Comma-separated list of Slack user IDs to exclude from reminders (optional)
- Click Deploy site
- Install Netlify CLI:
npm install -g netlify-cli - Login:
netlify login - Initialize:
netlify init - Set environment variables:
netlify env:set SLACK_TOKEN "xoxb-your-token-here" netlify env:set SLACK_SIGNING_SECRET "your-signing-secret-here" netlify env:set SLACK_WORKSPACE "useit" # or "t12t" for t12t workspace netlify env:set ALT_TEXT_GENERATION_API_KEY "your-api-key-here" netlify env:set EXCLUDED_USER_IDS "U12345678,U87654321" # Optional: comma-separated user IDs
- Deploy:
netlify deploy --prod
- After deployment, go to your Netlify site dashboard
- Navigate to Functions in the left sidebar
- Find
slack-eventsand copy its URL (it will look like:https://your-site.netlify.app/.netlify/functions/slack-events) - Go back to your Slack app settings → Event Subscriptions
- Paste the URL into Request URL
- Slack will verify the URL (you should see a checkmark)
- If verification fails, ensure:
- The function deployed successfully
- Environment variables are set correctly
- The URL is accessible (not behind authentication)
The bot needs to be invited to channels where you want it to monitor images:
- In Slack, go to any channel where you want the bot active
- Type
/invite @YourBotNameor use the channel settings to add the bot - The bot will now monitor that channel for images without alt text
