A script that notifies Slack on a regular basis (hourly, daily, or weekly). It uses Bun because Bun doesn't need to transpile TypeScript, and it has a fast startup time.
This script can be run with a cron job (or similar).
- If you don't have Bun, install it.
- Type
bun installto install the dependencies. - Create a Slack App that can receive incoming webhooks, and connect a webhook URL to a specific Slack channel.
- Create an environment variable named
SLACK_WEBHOOK_URLthat contains your URL (e.g.,export SLACK_WEBHOOK_URL=https://...). - Edit the
createMessagePayloadfunction in themessages.tsfile to customize your message. (See Slack's block builder tool if you want formatted messages.) - Run the script with
bun startorbun src/index.ts(with a cron job or manually).