Report this

What is the reason for this report?

How To Build a Slackbot in Python on Ubuntu 20.04 error

Posted on November 10, 2020

Hello I am following your steps using Mac os 14 (for environment variables, I have modified the steps where mac is different from ubuntu). I have setup the secret token, bot token and setup tunnel using ngrok. The event channel is verified on the slack page. I run the python app.py, the app starts properly but is unable to handle requests. I have not modified the script in any way. The error I get is

Exception on /slack/events [POST]
Traceback (most recent call last):
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/slackeventsapi/server.py", line 102, in event
    self.emitter.emit('error', slack_exception)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pyee/_base.py", line 111, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "/Users/wang.shuochen/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pyee/_base.py", line 83, in _emit_handle_potential_error
    raise error
slackeventsapi.server.SlackEventAdapterException: Invalid request signature
127.0.0.1 - - [10/Nov/2020 16:38:23] "POST /slack/events HTTP/1.1" 500 -

Any help is appreciated.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

This error is usually caused by an incorrect or mismatched Slack signing secret.

Please ensure that you have copied the correct signing secret from your app’s settings on the Slack API website, and ensure your Flask application is using the right secret as well.

If you continue to experience issues, consider reviewing the official Python Slack SDK guide on Webhooks and the example code on the Slack Python SDK GitHub.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.