Slackbot Quickstart Guide | Replit

Slackbot Quickstart Guide

A guide by
The Replit Team

Introduction

Using the Slack SDKs to automate work, notifications, or integrations can be a total productivity hack. This template makes use of the Slack Bolt framework for developing Slack Applications. Slack Bolt abstracts away most of the headaches associated with developing directly in the Slack SDK.

Using our template, you can have an interactive slack app up and running in 5 minutes with 18 lines of code.

Getting started

To get started building with Slack, fork this template by clicking "Use template".

Create new app

Create a new Slack app
Go to your apps dashboard here. Select "Create New App."

Use the manifest file

Use the app manifest file
On the "Create an app" screen, select the "From an app manifest" option. Then select the Slack Workspace you want to add your bot to. Then we will paste in the manifest. Here is your manifest:

{
    "display_information": {
        "name": "Hello World",
        "description": "A simple Slack Bot to say \"hi\" πŸ‘‹",
        "background_color": "#000000"
    },
    "features": {
        "app_home": {
            "home_tab_enabled": true,
            "messages_tab_enabled": true,
            "messages_tab_read_only_enabled": false
        },
        "bot_user": {
            "display_name": "Hello World",
            "always_online": false
        }
    },
    "oauth_config": {
        "scopes": {
            "bot": [
                "app_mentions:read",
                "channels:history",
                "channels:read",
                "chat:write"
            ]
        }
    },
    "settings": {
        "event_subscriptions": {
            "bot_events": [
                "app_mention"
            ]
        },
        "interactivity": {
            "is_enabled": true
        },
        "org_deploy_enabled": false,
        "socket_mode_enabled": true,
        "token_rotation_enabled": false
    }
}

The manifest defines the attributes of the bot. Examples include:

For more options, it's worth checking out the Slack documentation.

Install to workspace

Install your app to the Slack Workspace
On your app page, scroll down until you see the ability to "Install App to Workspace." Follow that process.

Add secrets

Scroll down to the "App credentials" section, and copy and paste the following credentials into the Secrets pane in Replit:

Running your bot

Once you have your application configured and tokens set, you can hit Run (⌘ + Enter) in Replit to execute app.py. Only 18 lines long, the app uses the Bolt framework to authenticate and configure your app in Socket mode. The only event listener in the app is:

@app.event("app_mention")
def event_test(event, say):
    say(f"Hi there, <@{event['user']}>!")

Which looks for a mention of your app's name. Head over to a channel where your app is a member (if it's not, you can add it with a mention) & give it a mention to see what happens!

Deploy your bot

With Replit, you can stop / start the Repl in development mode using ⌘ + Enter. Any changes saved in your files will be immediately and directly saved to your application. Check the Console pane (⌘ + K, "console") to see logs as they occur. Note that you'll need to stop & restart your application for changes to be reflected. This can be accomplished easily with the shortcut mentioned above.

When you're done developing, you can promote your app to a deployed version in one clickβ€” just head over to deployments (⌘ + K and type "deploy") to get started.

Note: For a Slack bot, we recommend using a Reserved VM, and then deploying it as a "background worker."

What's next

For next steps, you can use our guides to learn more about using Large Language Models (LLMs), and then you could integrate it into your Slackbot.