Use Python to Send Messages in Slack

Do you have a useful Python script that helps you accomplish a goal and you want to send the output to your team’s slack channel? Got you covered.

Assumptions

  • Python is installed and you know your basics.
  • You are using slack.

First things first. Open up Slack and create a new channel or use an existing channel. Click Add an app in the channel that you want to use.

In the Slack app directory search for webhooks and click Incoming WebHooks.

Click on Add Incoming WebHooks Integration.

Copy the webhook URL. Mine is blurred out, you cheeky monkey.

Now, create your Python script. Use my demo below. Save the file as a ‘py’ file and execute! If you don’t have the Requests library installed don’t forget to use:

pip3 install requests

The code:

And you’re done!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.