Send a message from Python to Slack

At the end of the time-consuming Python program, notify slack that the job is over.

Use slack-python-webhook.

my_tool.py


import slackweb
def message_to_slack(message):
    slack = slackweb.Slack(url="MY_SLACK_URL")
    slack.notify(text=message)

The My_URL part is obtained from incoming webhook.

When using

from my_tool import message_to_slack
message_to_slack("Job Completed!")

And so on.

Recommended Posts

Send a message from Python to Slack
Send a message from Slack to a Python server
I want to send a message from Python to LINE Bot
Create a setting in terraform to send a message from AWS Lambda Python3.8 to Slack
Send a message to LINE with Python (LINE Notify)
Post from Python to Slack
Post a message from IBM Cloud Functions to Slack in Python
[Python] Throw a message to the slack channel
How to install NPI + send a message to line with python
Changes from Python 3.0 to Python 3.5
Edit Excel from Python to create a PivotTable
How to open a web browser from python
How to generate a Python object from JSON
Sample to send slack notification with python lambda
[Python] Get one year's message history from Slack
POST messages from python to Slack via incoming webhook
[LINE Messaging API] I want to send a message from the program to everyone's LINE
Post to vim → Python → Slack
Cheating from PHP to Python
A road to intermediate Python
Post to slack with Python 3
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Send a signal to subprocess
Send data from Python to Processing via socket communication
Steps from installing Python 3 to creating a Django app
From buying a computer to running a program with python
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
Consider a conversion from a Python recursive function to a non-recursive function
Python script to create a JSON file from a CSV file
[Python] How to call a c function from python (ctypes)
How to create a kubernetes pod from python code
Post to Slack in Python
How to slice a block multiple array from a multiple array in Python
How to run a Python program from within a shell script
Summary from building Python 3.4. * From source to building a scientific computing environment
How to launch AWS Batch from a python client app
I want to start a lot of processes from python
Send experiment results (text and images) to slack with Python
Post a message to Google Hangouts Chat with a thread (Python)
Create a message corresponding to localization with python translation string
Send a request from AWS Lambda to Amazon Elasticsearch Service
Extract the value closest to a value from a Python list element
Call Matlab from Python to optimize
Call a Python function from p5.js.
How to write a Python class
Touch a Python object from Elixir
Create folders from '01' to '12' with python
Post from python to facebook timeline
[Lambda] [Python] Post to Twitter from Lambda!
How to make a slack bot
python / Make a dict from a list.
Connect to utf8mb4 database from python
Python (from first time to execution)
Post images from Python to Tumblr
Send commands from Atom to Maya
How to access wikipedia from python
Python to switch from another language
5 Ways to Create a Python Chatbot
[Python] Create API to send Gmail
Did not change from Python 2 to 3