1.7 KiB
whatsapp — WhatsApp Reminder System
Sends personalized WhatsApp reminders to users who haven't submitted their bets before the deadline. Uses OpenAI GPT-3.5 to generate natural-language reminder messages.
Classes
WhatsAppNotifier
Orchestrates the reminder workflow:
- Queries DB for upcoming reminders at 2 checkpoints: 24 hours and 2 hours before deadline
- For each reminder, generates a message via
OpenAIConnector - Sends via WhatsApp API (HTTP POST to configurable host:port)
- Marks sent reminders in DB to avoid duplicates
Requires env vars: TLW_WHATSAPP_HOST, TLW_WHATSAPP_PORT, TLW_WHATSAPP_API_KEY.
OpenAIConnector
Caches and generates reminder text via OpenAI Chat Completions API (model gpt-3.5-turbo-0125).
Prompt structure:
- System prompt (German): "Generate a message reminding someone to submit missing tips. Must sound like a friend. Use correct singular/plural."
- User input: JSON with league name, matchday name, delivery day, time
- Output template has 2 variants — 24h deadline uses a friendly intro, 2h deadline emphasizes urgency
Message format:
Hey <username>,
<AI-generated intro>
Bitte gib die fehlenden Tipps bis <today/morgen> um <HH:MM> ab.
Du kannst deine Tipps wie immer unter https://tippliga-wuerzburg.de/app.php/football/bet abgeben.
Viele Grüße
Die Tippliga Admins
Messages are cached per (league + matchday + delivery) key to avoid repeated API calls.
WhatsAppReminder
Java record with fields: season, league, leagueName, matchday, matchdayName, deliveryDate, todayTomorrow, time, remainingHours, userId, username, phoneNumber, missingBets.
Maps directly to the SQL query result from TippligaSQLConnector.getNextWhatsAppReminders().