Send Slack Messages with This Python Script! - Clearly explained | Slack API Bot

preview_player
Показать описание
With this video we will use Python and the SlackAPI to send automated messages to a Slack channel. For this we will build a Python based Slack Bot which uses Webhook URL for a selected channel and send customized messages based on the logic defined in your Python script.

I suggest to use few #Python functions which you can easily leverage for your business needs:
- The main() function provides a logic how the messages should be sent. You can customize this function upon your business requirements and extend the functionality as you want.
- send_slack_message() executes the message sending action to the specified Slack channel using the generated Webhook ID, which together with the message variable are sent to Slack API.

The tutorial demonstrated how to specify a payload which must be put into the POST request for the API. It is a key-values string formatted payload, where you should pay your attention to.

This Python tutorial does not requires any third-party dependencies, and uses the requests package only as the critical one.

Also, I built this bot to be able to receive messages to be sent to Slack channel from a terminal. For this I used argument receiver functionality originally provided by standard Python package argparse.

This Bot was developed on Python 3.8, but I think it would work on other versions also.

Table of the tutorial:
- 0:00 - Intro
- 0:23 - Build a Slack App and Get Webhook Token
- 3:32 - Coding part: build a Slack message sender with Python
- 8:57 - Set-up a Slack API payload variable
- 11:18 - Testing Python script, and debug development errors
- 13:25 - Sending more messages and customize the Bot logic

#SlackAPI #SlackBot
Рекомендации по теме
Комментарии
Автор

Thank you for watching this video. Automatization solutions takes a critical role in today's developing, especially in Machine Learning (ML). For this Machine Learning Operations (MLOps) discipline talks so much. Here are some more videos which falls into this topic you may like. Enjoy!

Subscribe the Data Science Garage channel to get more high quality videos! Thanks!

DataScienceGarage
Автор

Hi. amazing tutorial. I wanted to understand how we can send formatted text which contains elements like string, variables, bullets, etc via this method.

xmybxzw
Автор

Can i receive messages from slack to my application?

muhammadibrahim
Автор

How to send a reply from the Slack bot to the python app

learn-it-with-dinesh
join shbcf.ru