All Projects → slackapi → Python Slack Events Api

slackapi / Python Slack Events Api

Licence: mit
Slack Events API adapter for Python (Flask required)

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Python Slack Events Api

messaging-apis
Messaging APIs for multi-platform
Stars: ✭ 1,759 (+546.69%)
Mutual labels:  slack
python-slack-discovery-sdk
This project aims to make using Slack's Discovery APIs easier.
Stars: ✭ 18 (-93.38%)
Mutual labels:  slack
Query track
Find time-consuming database queries for ActiveRecord-based Rails Apps
Stars: ✭ 258 (-5.15%)
Mutual labels:  slack
slack.cr
Slack Real Time Messaging API in Crystal
Stars: ✭ 17 (-93.75%)
Mutual labels:  slack
react-slack-renderer
A custom Slack renderer for React! <3
Stars: ✭ 32 (-88.24%)
Mutual labels:  slack
slackblocks
🎲 Python API for Building Messages Using the Slack Block Kit API
Stars: ✭ 32 (-88.24%)
Mutual labels:  slack
WebsocketClientLite.PCL
websocket Client Lite PCL - Xaramrin
Stars: ✭ 22 (-91.91%)
Mutual labels:  slack
Slackr
#️⃣ A package to send webhook API messages to Slack.com channels/users from R
Stars: ✭ 269 (-1.1%)
Mutual labels:  slack
gSlack
Get Slack notifications from Google Cloud Platform
Stars: ✭ 69 (-74.63%)
Mutual labels:  slack
Slack Theme Cli
A CLI tool for changing Slack's desktop app colors
Stars: ✭ 256 (-5.88%)
Mutual labels:  slack
karmabot
upvotes and downvotes for slack
Stars: ✭ 24 (-91.18%)
Mutual labels:  slack
slack-status-based-on-wifi-name
Set your status on Slack based on the WiFi network you are connected to.
Stars: ✭ 30 (-88.97%)
Mutual labels:  slack
website-change-monitor
Monitor a website and get email and Slack notifications when specific changes are detected
Stars: ✭ 104 (-61.76%)
Mutual labels:  slack
slack-rs-api
Rust interface for the Slack Web API
Stars: ✭ 94 (-65.44%)
Mutual labels:  slack
Aws To Slack
Forward AWS CloudWatch Alarms and other notifications from Amazon SNS to Slack.
Stars: ✭ 261 (-4.04%)
Mutual labels:  slack
nomad-toast
A tool for receiving notifications based on HashiCorp Nomad events.
Stars: ✭ 40 (-85.29%)
Mutual labels:  slack
simple-slack-notify
Slack notification action that just works
Stars: ✭ 23 (-91.54%)
Mutual labels:  slack
Cordova Plugin Native Keyboard
🎹 Add a Slack / WhatsApp - style chat keyboard to your Cordova app!
Stars: ✭ 271 (-0.37%)
Mutual labels:  slack
Laravel Slack
#️⃣ Slack notification for Laravel as it should be. Easy, fast, simple and highly testable.
Stars: ✭ 263 (-3.31%)
Mutual labels:  slack
Alfred Slack
The Slack workflow for Alfred app
Stars: ✭ 254 (-6.62%)
Mutual labels:  slack

Slack Events API adapter for Python

.. image:: https://badge.fury.io/py/slackeventsapi.svg :target: https://pypi.org/project/slackeventsapi/ .. image:: https://travis-ci.org/slackapi/python-slack-events-api.svg?branch=main :target: https://travis-ci.org/slackapi/python-slack-events-api .. image:: https://codecov.io/gh/slackapi/python-slack-events-api/branch/main/graph/badge.svg :target: https://codecov.io/gh/slackapi/python-slack-events-api

The Slack Events Adapter is a Python-based solution to receive and parse events from Slack’s Events API. This library uses an event emitter framework to allow you to easily process Slack events by simply attaching functions to event listeners.

This adapter enhances and simplifies Slack's Events API by incorporating useful best practices, patterns, and opportunities to abstract out common tasks.

💡 We wrote a blog post which explains how_ the Events API can help you, why we built these tools, and how you can use them to build production-ready Slack apps.

.. _blog post which explains how: https://medium.com/@SlackAPI/enhancing-slacks-events-api-7535827829ab

⚠️ Important Notice

If you use this library for Events API handling, you may need to use threads for stable event acknowledgement. See https://github.com/slackapi/python-slack-events-api/issues/84 for details.

If you're looking for the best recommended library at this point, check Bolt for Python: https://github.com/slackapi/bolt-python

The framework covers not only Events API but also all the latest Slack Platform features.

🤖 Installation

.. code:: shell

pip install slackeventsapi

🤖 App Setup

Before you can use the Events API_ you must create a Slack App, and turn on Event Subscriptions.

💡 When you add the Request URL to your app's Event Subscription settings, Slack will send a request containing a challenge code to verify that your server is alive. This package handles that URL Verification event for you, so all you need to do is start the example app, start ngrok and configure your URL accordingly.

✅ Once you have your Request URL verified, your app is ready to start receiving Team Events.

🔑 Your server will begin receiving Events from Slack's Events API as soon as a user has authorized your app.

🤖 Development workflow:

(1) Create a Slack app on https://api.slack.com/apps (2) Add a bot user for your app (3) Start the example app on your Request URL endpoint (4) Start ngrok and copy the HTTPS URL (5) Add your Request URL and subscribe your app to events (6) Go to your ngrok URL (e.g. https://myapp12.ngrok.com/) and auth your app

🎉 Once your app has been authorized, you will begin receiving Slack Events

⚠️  Ngrok is a great tool for developing Slack apps, but we don't recommend using ngrok
for production apps.

🤖 Usage

⚠️ Keep your app's credentials safe!

  • For development, keep them in virtualenv variables.

  • For production, use a secure data store.

  • Never post your app's credentials to github.

.. code:: python

SLACK_SIGNING_SECRET = os.environ["SLACK_SIGNING_SECRET"]

Create a Slack Event Adapter for receiving actions via the Events API

Using the built-in Flask server:

.. code:: python

from slackeventsapi import SlackEventAdapter

slack_events_adapter = SlackEventAdapter(SLACK_SIGNING_SECRET, endpoint="/slack/events")

Create an event listener for "reaction_added" events and print the emoji name

@slack_events_adapter.on("reaction_added") def reaction_added(event_data): emoji = event_data["event"]["reaction"] print(emoji)

Start the server on port 3000

slack_events_adapter.start(port=3000)

Using your existing Flask instance:

.. code:: python

from flask import Flask from slackeventsapi import SlackEventAdapter

This app represents your existing Flask app

app = Flask(name)

An example of one of your Flask app's routes

@app.route("/") def hello(): return "Hello there!"

Bind the Events API route to your existing Flask app by passing the server

instance as the last param, or with server=app.

slack_events_adapter = SlackEventAdapter(SLACK_SIGNING_SECRET, "/slack/events", app)

Create an event listener for "reaction_added" events and print the emoji name

@slack_events_adapter.on("reaction_added") def reaction_added(event_data): emoji = event_data["event"]["reaction"] print(emoji)

Start the server on port 3000

if name == "main": app.run(port=3000)

For a comprehensive list of available Slack Events and more information on Scopes, see https://api.slack.com/events-api

🤖 Example event listeners

See example.py_ for usage examples. This example also utilizes the SlackClient Web API client.

.. _example.py: /example/

🤔 Support

Need help? Join Slack Community_ and talk to us in #slack-api_.

You can also create an Issue_ right here on GitHub.

.. _Events API: https://api.slack.com/events-api .. _create a Slack App: https://api.slack.com/apps/new .. _Event Subscriptions: https://api.slack.com/events-api#subscriptions .. _Slack Community: http://slackcommunity.com/ .. _#slack-api: https://dev4slack.slack.com/messages/slack-api/ .. _create an Issue: https://github.com/slackapi/python-slack-events-api/issues/new

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].