This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!
Project Description


Flask-SlackBot is a Flask extension which helps you deal with slack’s outgoing webhook.


$ pip install flask-slackbot


# coding=utf-8
from flask import Flask

from flask_slackbot import SlackBot

app = Flask(__name__)
app.config['SLACK_TOKEN'] = 'Your token here'
# if you need to use slacker you should give a slack chat token
app.config['SLACK_CHAT_TOKEN'] = 'Your slack chat token'
app.config['SLACK_CALLBACK'] = '/slack_callback'
app.debug = True
slackbot = SlackBot(app)

The parameter of the callback function is a dict returns from the slack's outgoing api.
Here is the detail:
    'token': token,
    'team_id': team_id,
    'team_domain': team_domain,
    'channel_id': channel_id,
    'channel_name': channel_name,
    'timestamp': timestamp,
    'user_id': user_id,
    'user_name': user_name,
    'text': text,
    'trigger_word': trigger_word
def fn1(kwargs):
    This function shows response the slack post directly without an extra post.
    In this case, you need to return a dict.'''
    return {'text': '!' + kwargs['text']} # Note the '!' character here is an user defined flag to tell the slack, this message is sent from the bot.

def fn4(kwargs):
    This function looks like upper one. But a little different, this will only response to the sender.
    In this case, you need to return a dict with an extra key private setted as True.
    And if you need this function, you should given the slack chat token in config.'''
    return {'text': '!' + kwargs['text'], 'private': True} # Note the '!' character here is an user defined flag to tell the slack, this message is sent from the bot.

def fn2(kwargs):
    This function shows response the slack post indirectly with an extra post.
    In this case, you need to return None.
    Now the slack will ignore the response from this request, and if you need do some complex task you can use the built-in slacker.
    For more information, see''''#general', 'hello from slacker handler')
    return None

def fn3(text):
    This function is a filter, which makes our bot ignore the text sent from itself.'''
    return text.startswith('!')


if __name__ == "__main__":


If you have not set a trigger word, and your callback server return some text to slack, there would be a callback hell. You know like ping pong, and then turn into an infinite loop.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (9.0 kB) Copy SHA256 Checksum SHA256 Source Jun 24, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting