Nevertheless, if there's popular demand, we could add support for them. Note: Legacy actions are unsupported by design as they are discouraged by slack. Yes! See examples/actions.py for a quickstart. Of course! See examples/views.py for a quick example Are interactive actions supported? Yes, See examples/shortcuts.py for a self contained example And can i use new slack Modals? Heroku might be a good choice if you are just getting started as it has a generous free tier.
Python slack client reples update#
Once your bot is ready for production you should update your commands url to a permanent one. *This is a development setup so you can quickly see your code changes in slack without the need to redeploy your whole site. Write /hello to your new slack bot and let the magic begin.Run your app with flask run -port=5000 (The port should match the one on step #1).On your terminal export flask app variable export FLASK_APP='quickstart:app'.Create a slash command and set the url to ngrok's https url of step #1.Download ngrok* and run ngrok http 5000 to create a https proxy to localhost.
To connect it to slack you need to meet this preconditions: command ( name = 'say_bye' ) def bye (): my_background_job () return reply_text ( 'Bye' ) def my_background_job (): """Non blocking long task""" sleep ( 15 ) return command def hello (): return reply_text ( 'Hello from Slack' ) # Change the slash command name to /say_bye instead of the default function name. Replace it by gunicorn or similar when ready to shipĬreate a file named quickstart.py with the following content from flask import Flask from slackify import Slackify, async_task app = Flask ( _name_ ) slackify = Slackify ( app = app ). This setup uses flask builtin server which is NOT suited for production. The server will listen at / for commands/actions and /slack/events for slack events To do so, it stands on the shoulders of Flask and slackclient ( The official python slack client) and offers a more declarative API over slack commands, events, shortcuts, actions and modals.
Python slack client reples how to#
Slackify is a light framework designed to accelerate your development of slack apps by letting you focus on what you want instead of fighting with how to do it