A2Bot is an AI-powered WhatsApp assistant that helps track daily calories automatically through natural conversation in group chats.
This project is built to facilitate diet tracking without the need to open a separate app. Simply chat "Ate fried rice", and the AI will estimate the calories for you.
- 🧠 AI-Powered Tracking: Uses Google Gemini 2.5 Flash to recognize food types and estimate calories from everyday language.
- 💬 WhatsApp Integration: Runs directly in WhatsApp Groups or Personal Chats.
- 👥 Multi-User Support: Distinguishes tracking for each group member (e.g., You and your Partner).
- 📊 Real-time Database: Stores daily progress using a simple local JSON database.
- 🔒 Secure Configuration: Uses
.envto protect your API keys (Security Best Practice). - ⚡ Fast Response: Lightweight and fast using the
@whiskeysockets/baileyslibrary.
- Node.js - Runtime environment.
- Baileys - WhatsApp Web API Library (Unofficial).
- Google Generative AI - The brain behind calorie estimation.
- Dotenv - For managing environment variables securely.
Follow these steps to run the bot on your local computer or server.
- Node.js installed on your computer.
- API Key from Google AI Studio.
1. Clone Repository
git clone https://github.com/eeryyy282/double-a-calorie.git
cd double-a-calorie2. Install Dependencies
npm install3. Configure Environment Variables
Create a new file named .env in the root directory and add your API Key inside it. This keeps your key safe and out of the code.
API_KEY=your_actual_gemini_api_key_hereNote: The .env file is ignored by Git to prevent accidental leakage of your secrets.
4. Run Bot
node index.js5. Scan QR Code
The terminal will display a QR Code. Open WhatsApp on your phone (a dedicated bot number is recommended), go to Linked Devices, and scan the QR code.
Once the bot is connected (✅ A2Bot successfully connected!), you can start using it immediately.
- Start: Send any message (e.g., "Hello") to the bot number. The bot will automatically create your profile with a default target.
- Input Food:
- "Lunch with chicken soup and half a portion of rice"
- "Just drank iced coffee with brown sugar"
- "Snacking on one fried banana"
- Response: A2Bot will reply with the calorie estimation and your remaining calorie allowance for the day.
This project uses an Unofficial WhatsApp library (Baileys). Use wisely. There is a risk of the WhatsApp number being banned if used for spamming. Using a secondary number is recommended. Communication and UI messages use Bahasa Indonesia.
