# Slackbot Quickstart Guide

A guide by  
[The Replit Team](/content/site-root.html)

# 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](https://api.slack.com/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](/content/@replit-matt/Slack-App-Template?v=1#README.md) by clicking "Use template".

# Create new app  
  
Create a new Slack app  
Go to your apps dashboard [here](https://api.slack.com/apps). 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:

```json
{
    "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:

- **display_information** - The name, description, and background color of the bot
- **features** - home tab, messages tab, display_name, and more for the bot
- **oauth_config** - Defined permissions for the application. In this case, the bot can read messages that mention the app (app_mentions:read), view messages in public channels (channels:history), read info on public channels (channels:read), and send messages (chat:write)
- **settings** - miscellaneous attributes like event_subscriptions, interactivity, and more

For more options, it's worth checking out the [Slack documentation](https://api.slack.com/docs).

# 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:

- **SLACK_SIGNING_SECRET** - The "signing secret" for your app, found on the "Basic Information Page"
- **SLACK_APP_TOKEN** - The [app-level token](https://api.slack.com/authentication/token-types#app), found under "App Credentials" on the "Basic Information" page
- **SLACK_BOT_TOKEN** - The bot token for your app, found on the "OAuth & Permissions" page

# 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:

```python
@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.
