Issue
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.
Solution
I was missing the message.channels permission under the Application Settings > Event Subscriptions > Subscribe Bot to Events.
Answered By - spyderman4g63
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.