This project is a lightweight Slack bot that posts an AI-generated message to a Slack channel every six hours using OpenAI’s API.
Find a way to ensure that a computer on a local network is powered on and its operations are functional.
Due to security concerns, our IT team wasn't comfortable forwarding a port on our local network to expose it to the internet, so I designed this bot to act as a de-facto ping. The idea was that if I don't get a slack notification from the bot every six hours, I'll know to check that the computer is still running.
To make this more interesting (as opposed to just posting the same message over and over), I decided to make the bot prompt the OpenAI api to post to the Slack channel.
The bot has gone through several iterations, including:
- Dark-humored haikus
- Jokes
- Horoscopes
- A “word of the day” (current implementation)
Early versions of the word-of-the-day prompt resulted in frequent repetition. To improve variety, the bot now:
- Randomly selects a starting letter
- Prompts OpenAI to return a word beginning with that letter
This ensures fresh output while keeping the prompt simple and deterministic.
The bot is scheduled to run every 21600 seconds (six hours) via a plist.
- A scheduled job runs every six hours.
- The script:
- Generates a prompt for OpenAI
- Requests a short response (e.g., a word of the day and definition)
- The generated content is posted to a designated Slack channel.
- Receipt of the message confirms:
- The machine is powered on
- Network access is functional
- The runtime environment and credentials are valid
-
flippy_slack.py
Main execution script. Handles prompt generation, OpenAI interaction, and Slack message posting. -
config.py
Centralized configuration and environment variable loading. -
com.flippy_slack.plist
macOS LaunchAgent configuration used to schedule execution every 21,600 seconds (six hours). -
requirements.txt
Python dependencies required to run the bot. -
README.md
Project documentation.
- Python 3.9+
- macOS (for scheduled execution using
launchd) - A Slack bot token with permission to post messages
- An OpenAI API key
pip install -r requirements.txt