Slack Pings Bot

Requirements

  1. Python 3.10+ https://www.python.org/downloads/

Creating the bot on Slack

  1. Go to https://api.slack.com/
  2. Log into your account. You may be redirected to another page. Please return to the page above if redirected after logging in
  3. Click on Create a new App
  4. Choose from Manifest
  5. Choose JSON
  6. Copy all the contents in the manifest.json file inside this folder and paste it there
  7. Create bot
  8. Install bot in your workspace. Copy the bot token and paste it inside of the quotation marks in the SLACK_BOT_TOKEN variable in the settings.json file
  9. Copy the app token and paste it inside of the quotation marks in the SLACK_APP_TOKEN variable in the settings.json file.

Installation

  1. Extract the zip onto a folder
  2. Open terminal or CMD and cd onto the folder. (If you're on mac just drag the folder to the terminal!)
  3. Rename sample_settings.json to settings.json
  4. Run python3 main.py or py main.py
  5. The bot is running!

Purpose: The Slack-Pings-Bot is a Python bot for Slack that tracks when users are mentioned (pinged) in messages and displays these pings in the user's Slack home tab.

Main Features:

Message Tracking: When a message contains a user mention (e.g., <@user_id>), the bot saves the message link, the person who pinged, and the person who was pinged in a local SQLite database. Home Tab Notifications: When a user opens their Slack app home tab, the bot displays a list of all pings (mentions) they have received, showing who pinged them and providing a direct link to the relevant message. Dismissal Actions: Users can dismiss individual pings from their home tab via a button, which removes that ping from the database. No Pings Message: If a user has no pings, the bot shows a message saying "You have no pings". Setup:

You must create a Slack app, install it in your workspace, and provide bot/app tokens in a settings.json file. The bot runs as a Python script (main.py) and uses Slack Bolt for event handling. Technical Details:

Uses sqlite3 for local storage of pings. Handles Slack events: message (to track mentions) app_home_opened (to display pings) Provides interactive Slack UI blocks (with buttons) for dismissing notifications.

Built With

Share this project:

Updates