Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I read chat messages with the Slack Bolt library?

I have created a slack app. I'm able to read and respond to slash commands. However, the application cannot read messages. When I issue a slash command I see a web server event like this:

127.0.0.1 - - [19/Jan/2021 13:11:07] "POST /slack/events HTTP/1.1" 200 -

However, when a text message is entered into the chat there is no log on my webserver. I believe a slack message should trigger an event that sends data to my API. Note: I am using the event API.

I'm using Bolt for slack.

I'm assuming the permissions for this are in the Event Subscriptions settings under Subscribe to bot events. In this case I have only enabled app_home_opened.

There is an option for channels:read and channels:history. They are both bold and not able to be added. I assume this means they are enabled by default.

Here is a simplified application that responds to /list but doesn't respond to hello:

import os
from slack_bolt import App

# Initializes the app
app = App(
    token=os.environ.get("SLACK_BOT_TOKEN"),
    signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
)

# Respond to hello
@app.message("hello")
def say_hello(message, say):
    say("hi")

# List all users
@app.command("/list")
def list_users(ack, say, command):    
    ack()
    say("list users")

# Start your app
if __name__ == "__main__":
    app.start(port=int(os.environ.get("PORT", 3000))) 

I believe that channels:history is the permission I need to view the chat content. Why can't I read and respond to messages?

This is the documentation I'm trying to refer to for the events API.

like image 928
spyderman4g63 Avatar asked Aug 31 '25 02:08

spyderman4g63


1 Answers

I was missing the message.channels permission under the Application Settings > Event Subscriptions > Subscribe Bot to Events.

like image 121
spyderman4g63 Avatar answered Sep 02 '25 17:09

spyderman4g63