Need help for running Flask app using this package
Hi I am using slack api to render the automatic message reply from the slack boat
This is My Code:
ss = "***"
slack_event_adapter = SlackEventAdapter(ss,'/slack/events',app)
print("slack_event_adapter:",slack_event_adapter)
print("slack_event_adaptor_event_name",slack_event_adapter.on('message'))
@slack_event_adapter.on('message')
def message(payload):
# def message(payload):
st = "xoxb-***"
client = slack.WebClient(token=st)
BOT_ID = client.api_call("auth.test")['user_id']
print("BOT_ID",BOT_ID)
print("Hiii")
event = payload['event']
print(event)
channel_id = event.get('channel')
print("channel_id",channel_id)
# channel_id ='#sample'
user_id = event.get('user')
print("user_id",user_id)
# user_id = "Manikantha Sekhar"
text = event.get('text')
print("test:",text)
# text = "Hi"
if BOT_ID != user_id:
print("if_condition")
print("bot_id not equal")
#msg = "this is arkatiss new experiment"
reply = reply_the_user(text,user_id)
print("reply",reply)
client.chat_postMessage(channel=channel_id,text=reply)
# # message()
if __name__ == "__main__":
app.run(host='localhost',debug=False,port=5030)
This is my payload through postman
{ "event":"message",
"channel_id":"C03NNTWTE1F",
"user_id": "U01DQQR0ZK8",
"text":"hi"
}
This is my url
1.http://localhost:5030/slack/events/ getting error like
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try
again.</p>
any solution for this can you help me in this
Hi
sdk.web/webhook/rtm package instead. For more info, go to https://slack.dev/python-slack-sdk/v3-migration/
warnings.warn(message)
* Serving Flask app 'slack_bot' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2022-07-22 12:07:18,774] ERROR in app: Exception on /slack/events [POST]
Traceback (most recent call last):
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2070, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1515, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1513, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1499, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\slackeventsapi\server.py", line 102, in event
self.emitter.emit('error', slack_exception)
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\pyee\base.py", line 179, in emit
self._emit_handle_potential_error(event, args[0] if args else None)
File "C:\Users\Arkatiss123\AppData\Local\Programs\Python\Python36\lib\site-packages\pyee\base.py", line 139, in _emit_handle_potential_error
raise error
slackeventsapi.server.SlackEventAdapterException: Invalid request signature
127.0.0.1 - - [22/Jul/2022 12:07:18] "POST /slack/events HTTP/1.1" 500 -
getting this
i installed the ngrok and I enable the events section and passed the url
still getting error please find below screen shot
could any one help me with this
Thank you Manikantha
Hi @mady143, thanks for writing in.
slackeventsapi.server.SlackEventAdapterException: Invalid request signature
This error indicates your loaded signing secret might be wrong. Could you double-check whether you've passed a valid value to SlackEventAdapter constructor?
Also, our latest recommendation is to use bolt-python, which is more robust and covers full features of the Slack platform. Here is a simple Flask app examples: https://github.com/slackapi/bolt-python/tree/main/examples/flask If you don't have any particular reason to use this slackeventsapi package, please try slack-bolt package instead!
Let us close this issue due to its inactivity. As mentioned above, we recommend using bolt-python instead. If you have further questions with bolt-python, please feel free to ask questions at https://github.com/slackapi/bolt-python/issues/new/choose