[Python] Throw a message to the slack channel

what's this

There are many cases where you are running a batch and want to be notified when it ends or an abnormality occurs. Recently, the method of "using Slack for notification" is popular among me. What makes me happy is that I can immediately check it on my mobile phone or computer. And if it's a Slack channel, you can get the people involved right away. I use it when I want to create an oleore monitor for a specific service immediately.

Things necessary

How to use

Please rewrite the token of the script below to your own token. In the example below, #uhouho_channnel has a user named tsukune. Tweet "Chiss".

pip install

pip install slackclient

Code example

from slackclient import SlackClient

def post_slack(message):
    sc = SlackClient(token)

if __name__ == '__main__':

Recommended Posts

[Python] Throw a message to the slack channel
Send a message from Python to Slack
Send a message from Slack to a Python server
Post a message from IBM Cloud Functions to Slack in Python
Send a message to LINE with Python (LINE Notify)
How to notify a Discord channel in Python
A python amateur tries to summarize the list ②
Create a setting in terraform to send a message from AWS Lambda Python3.8 to Slack
Python Note: The mystery of assigning a variable to a variable
Post from Python to Slack
Post to vim → Python → Slack
A road to intermediate Python
Post to slack with Python 3
Post to Slack in Python
Add a function to tell the weather of today to slack bot (made by python)
How to install NPI + send a message to line with python
[python] Change the image file name to a serial number
How to use the __call__ method in a Python class
Change the standard output destination to a file in Python
Probably the easiest way to create a pdf with Python3
Build a Python environment and transfer data to the server
I want to send a message from Python to LINE Bot
[Python] The first step to making a game with Pyxel
Create a message corresponding to localization with python translation string
Extract the value closest to a value from a Python list element
How to write a Python class
Leave the troublesome processing to Python
In the python command python points to python3.8
How to get the Python version
[Python] Make the function a lambda function
[Python] Change the alphabet to numbers
How to determine the existence of a selenium element in Python
[Introduction to Python] How to split a character string with the split function
A story that struggled to handle the Python package of PocketSphinx
I created a Python library to call the LINE WORKS API
How to check the memory size of a variable in Python
Create a shell script to run the python file multiple times
[Introduction to Python] How to use the in operator in a for statement?
How to check the memory size of a dictionary in Python
I tried to make a 2channel post notification application with Python
[Python3] Define a decorator to measure the execution time of a function
Slack --APIGateway --Lambda (Python) --How to make a RedShift interactive app
I wanted to solve the ABC164 A ~ D problem with Python
A script that returns 0, 1 attached to the first Python prime number
How to send a request to the DMM (FANZA) API with python
[python] A note that started to understand the behavior of matplotlib.pyplot
[Python] A simple function to find the center coordinates of a circle
[Python] A program that rotates the contents of the list to the left
Write a script in Shell and Python to notify you in Slack when the process is finished
[Slack api + Python] I tried to summarize the methods such as status confirmation and message sending
The story of creating a bot that displays active members in a specific channel of slack with python
[Python] What is a formal argument? How to set the initial value
Have Alexa run Python to give you a sense of the future
[Introduction to Python] What is the difference between a list and a tuple?
[Python] How to make a class iterable
[Introduction to Udemy Python3 + Application] 47. Process the dictionary with a for statement
Write the test in a python docstring
Give a title to the ipywidgets tab
[Python] Explains how to use the range function with a concrete example
A super introduction to Python bit operations
[Python] A program that calculates the number of socks to be paired