Slack Bot With Bolt

Within the Slack website

Go to api.slack.com , go to “Your Apps”, and “Create App”.

Enable Socket Mode, and in token add “connections::write”.

In the OAuth and Permissions tab, add the Bot Token Scopes. If you change these later, you will need to re-install the app to the workspace.

Install to workspace.

Event Subscriptions need to be enabled.

(Sidenote: There's an alternate navigation flow in my notes - from the “Add Apps”, “Bots”, “Add to Slack”. I do not remember the context now.)

Coding

Install the needed libraries with: “pip install slack_bolt aiohttp”

Then, use this code:

from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
 
app_token = "from basic info path"
bot_token = "from oauth section"
 
app = App(token=bot_token)
handler = SocketModeHandler(app, app_token)
 
@app.event("app_mention")
def handle_mention(event, client, say):
    client.reactions_add(
        channel = event["channel"],
        timestamp = event["ts"],
        name = "eyes"
    )
    print(say)
    print(event)
 
handler.start()