This application is a NestJS-based command line utility that sends the current temperature of the Limmat river in Zurich along with an encouraging message in German to a specified WhatsApp number. The temperature data is fetched from HydroProWeb, and the encouraging message is generated using ChatGPT, powered by OpenAI.
- Fetches the current water temperature of the Limmat river in Zurich.
- Generates an encouraging message in German using ChatGPT.
- Sends the combined message (temperature + encouraging message) to a specified WhatsApp number.
- Node.js (Version 21 recommended)
- A NestJS environment
- An OpenAI API key for ChatGPT message generation
- A WhatsApp number and a CallMeBot API key for message sending
-
Clone the repository
git clone <repository-url> cd <repository-name>
-
Install Dependencies
Run
npm install
to install the required packages. -
Set Environment Variables
You need to set up the following environment variables:
OPENAI_API_KEY
: Your OpenAI API key for accessing ChatGPT.PHONE_NUMBERS
: The WhatsApp numbers where the message will be sent (seperated by a comma).CALL_ME_BOT_API_KEYS
: Your CallMeBot API keys for sending WhatsApp messages (seperated by a comma).
These can be set in a
.env
file in your project root or configured as secrets in your GitHub repository for GitHub Actions. -
Build the Project
Compile the TypeScript source code to JavaScript using NestJS CLI:
npm run build
-
Run the Command
Execute the command to send the WhatsApp message:
npm run start:prod -- generate-ice-bath-message
The GitHub Action Run NestJS Command
is configured to automate the execution of the generate-ice-bath-message
command under certain conditions.
- On Push/Pull Request to Main Branch: The action is triggered whenever code is pushed to the main branch or a pull request is made against it.
- Scheduled Runs: Additionally, the command is scheduled to run automatically at 09:00 UTC every day.
- Checkout: The latest code is checked out from the main branch.
- Set up Node.js: Node.js is set up with the specified version (21), ensuring compatibility.
- Install Dependencies: All project dependencies are installed using
npm ci
for a clean installation. - Build the Project: The project is built using
npm run build
, compiling the TypeScript code. - Run NestJS Command: The
generate-ice-bath-message
command is executed with necessary environment variables (OPENAI_API_KEY
,PHONE_NUMBERS
,CALL_ME_BOT_API_KEYS
) provided from the repository's secrets.
This GitHub Action ensures that the application can automatically send out messages based on the schedule or code updates, keeping the information flow automated and up-to-date.