Slack Events adapter not getting triggered


I am trying to build a basic slack bot but the bot is not picking up the message event. Have added the following scopes: "chat:write"

Have also subscribed for the event message.channels.

I have configured ngrok server. When I hit the endpoint from my browser I get a message saying "these are not the slack bots you are looking for" which means the server is running. But when I post a message in the channel in which the bot is added, the API is not triggered. can you please help with this?

Here is the code that I’m using:

import slack_sdk
import os
from pathlib import Path
from dotenv import load_dotenv
from flask import Flask
from slackeventsapi import SlackEventAdapter

env_path = Path('.') / '.env'
load_dotenv(dotenv_path = env_path)

app = Flask(__name__)
slack_event_adapter = SlackEventAdapter(os.environ['SIGNING_SECRET'],'/slack/events',app)

client = slack_sdk.WebClient(token = os.environ['SLACK_TOKEN'])

# client.chat_postMessage(channel = '#bi-announcements', text = "Hello World! ")

BOT_ID = client.api_call("auth.test")['user_id']

def message(payload):
    event = payload.get('event',{})
    channel_id = event.get('channel')
    user_id = event.get('user')
    text = event.get('text')

    if BOT_ID != user_id:
        client.chat_postMessage(channel= channel_id, text = text)

if __name__ == "__main__":

Here are the slack configurations:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

I’m able to send messages to slack but not able to read the messages. Any help would be greatly appreciated.


As discussed in comments, there was a rare occurrence that the created app somehow was faulty.

Creation of a new app with same configuration solved the issue.

Answered By – Suyash Gaur

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published