[PYTHON] Make Slack chatbot with Errbot

Continuation of http://qiita.com/attakei/items/29b3f0086296345216df

This time I will try to initially build an Errbot that monitors Slack and works.

Things to prepare

Edit config.py for Slack

config.py


#Near L47
#Specify the chat backend. This time specify Slack here
BACKEND = 'Slack'  # defaults to XMPP

#Near L135
 BOT_IDENTITY = {
     #Comment out the XMPP part
     # XMPP (Jabber) mode
     # 'username': 'err@localhost',  # The JID of the user you have created for the bot
     # 'password': 'changeme',       # The corresponding password for this user

#Near L152
    #You need a token to use Slack, so specify the token that is commented out
    # Slack mode (comment the others above if using this mode)
    'token': 'xoxb-your-slack-token',

#Near L179
#A list of accounts that have administrative privileges for this Errbot.@The one who starts from
BOT_ADMINS = ()

#Near L185
#The rooms and channels in which this Errbot participates. This time I will talk alone so empty tuples
CHATROOM_PRESENCE = ()

Try to start

At the terminal


$ errbot
12:34:47 INFO     errbot.err                Config check passed...
12:34:47 INFO     errbot.err                Selected backend 'Slack'.
(Abbreviation)
12:34:48 INFO     errbot.main               Found Backend plugin: 'Slack'
12:34:48 INFO     errbot.backends.slack     Verifying authentication token
12:34:50 INFO     requests.packages.urllib3 Starting new HTTPS connection (1): slack.com
12:34:52 INFO     errbot.backends.slack     Connecting to Slack real-time-messaging API
12:34:52 INFO     requests.packages.urllib3 Starting new HTTPS connection (1): slack.com
12:34:56 INFO     errbot.backends.slack     Connected
(Abbreviation)
12:34:57 INFO     errbot.errBot
12:34:57 INFO     errbot.errBot             Notifying connection to all the plugins...
12:34:57 INFO     errbot.plugins.ChatRoom   Callback_connect
12:34:57 INFO     errbot.errBot             Plugin activation done.
12:34:58 INFO     requests.packages.urllib3 Starting new HTTPS connection (1): slack.com

It connects to slack's messaging API.

Try to talk

I4RM7l5QoK.gif

Terminal side


13:05:04 INFO     errbot.plugins.ACLS       Matching ACL {} against username @attakei for command Help:help
13:05:04 INFO     errbot.plugins.ACLS       Check if help is admin only command.
13:05:04 INFO     errbot.errBot             Processing command 'help' with parameters '' from @attakei

Looking at the log, "from whom" and "what command" is output.

After that, if you put it somewhere on heroku, the chatbot is completed

Recommended Posts

Make Slack chatbot with Errbot
Introduce errBot and work with Slack
Make Lambda Layers with Lambda
Make Yubaba with Discord.py
Errbot: Python chatbot basics
Slack chatbot creation Python
Make slides with iPython
What is God? Make a simple chatbot with python
Pomodoro timer made with Errbot
Let's make Othello with wxPython
Let's make an Errbot plugin
Easy to make with syntax
Make Puyo Puyo AI with Python
Let's make dice with tkinter
Make a fortune with Python
Implement Slack chatbot in Python
Make a fire with kdeplot
Make Echolalia LINEbot with Python + heroku
Easy Slackbot with Docker and Errbot
Let's make a GUI with python.
Make a sound with Jupyter notebook
How to make a slack bot
Let's make a breakout with wxPython
Let's make Othello AI with Chainer-Part 1-
Make testing with Selenium more accessible
Make a recommender system with python
Make a filter with a django template
Let's make a graph with python! !!
Let's make a supercomputer with xCAT
Easy with Slack using Bot #NowPlaying
Let's make Othello AI with Chainer-Part 2-
Make a model iterator with PySide
Make Scrapy an exe with Pyinstaller
Make a nice graph with plotly