
Hello, Cuan Friend! Do you often forget to record your daily expenses? Or dizzy looking at a pile of shopping receipts? Relax, today we will make a super sophisticated solution: Personal Finance Bot on WhatsApp!
Imagine, you can simply send a message or photo of the receipt to WhatsApp, and voila! All transactions are immediately recorded neatly in Google Sheets. Cool, right? This bot uses the power of Google Gemini AI to understand your language, and can even read the writing on the receipt!
Ready to create your personal finance assistant? Let's get started!
Cool Features You'll Get:
Before we get into the technical steps, let's take a peek at the sophistication of the bot we are about to create:
- 📱 Directly from WhatsApp: Record transactions without the need to open another application.
- 🤖 Powered by AI Gemini: Bots can understand messages like
"yesterday's coffee snack 25 thousand"and automatically process it. - 🖼️ Can Read Receipts: Simply take a photo of your receipt, and AI will extract the information automatically.
- 📊 Saved in Google Sheets: All data is safe and neatly stored in your spreadsheet.
- 📈 Instant Financial Report: Request a summary of totals, details per category, or transaction history at any time.
- 🔐 Safe and Private: Set the bot to respond to your number only.
Preparation Before You Start
Make sure you have prepared the following "ingredients":
- Node.js (version 16 or later). how to install here
- Google account with access to Google Sheets.
- API Key of Gemini AI.
- Of course, a WhatsApp account!
Step 1: Project Installation
First, let's set up the project on your computer.
- Clone or download this project from repository-her.
- Open the terminal or command prompt, enter the project directory, and run this command to install everything needed:
npm installStep 2: Setting up Google Secret Key (Service Account)
For the bot to write in Google Sheets, we need to create a special "key".
- Go to Google Cloud Console.
- Create a new project or select an existing project.
- Activate Google Sheets API in your project.
- Create Service Account:
- Open menu IAM & Admin > Service Accounts.
- Click Create Service Account, give it a cool name, for example "Personal Finance Bot".
- Just skip the part role (click "Continue") and click "Done".
- Create JSON Credentials:
- Click email service account that you just created.
- Enter the tab Keys.
- Click Add Key > Create new key.
- Select format JSON, and the file will automatically download.
- Rename the file to
credentials.jsonand place it inside the main folder of your project.
Step 3: Setting up Google Sheets
This is the place where all your data will be stored.
- Create a new Google Spreadsheet.
- Click the button Share in the top right corner.
- Copy email service account of the file
credentials.json(usually in theclient_email), then paste it in the column Share and grant access as Editor. - Copy Spreadsheet ID of the URL. Example:
https://docs.google.com/spreadsheets/d/[INI-ADALAH-SPREADSHEET-ID-NYA]/edit
Step 4: Get Gemini AI API Key
This is the brain of our bot!
- Visit Google AI Studio.
- Click to create a new API Key.
- Copy and save the API key carefully.
Step 5: Project Environment Configuration
Time to put all the keys and IDs we've collected together!
The Easy Way (Recommended): Run this command in the terminal and follow the interactive instructions. Super easy!
npm run setupManual Way:
- Copy file
.env.exampleand rename it to.env. - Open file
.envand fill in all the values:
GEMINI_API_KEY=insert_your_gemini_key
GOOGLE_SHEETS_CREDENTIALS=./credentials.json
SPREADSHEET_ID=enter_your_spreadsheet_id
USER_ID=create_unique_id_for_you_malal_user01
AUTHORIZED_NUMBERS=6281234567890,6289876543210Step 6 (Optional): Set Allowed WhatsApp Numbers
Want your bot to be exclusive to you? You can set it up at AUTHORIZED_NUMBERS.
- Leave it blank: The bot will reply to all numbers that send messages.
- Fill in your number: The bot will only respond to registered numbers.
- Number Format: Use unmarked international format
+. Example:6281234567890. - For multiple numbers, separate them with commas.
- Number Format: Use unmarked international format
Step 7: Bot Health Test
Before running it, make sure all configurations are correct by running this test:
npm run healthStep 8: Run the Bot!
Here comes the moment you've been waiting for!
- Start the bot with commands:
npm start- A QR code will appear on your terminal.
- Open WhatsApp on your phone, go to the menu Linked Devices, and scan the QR code.
Congratulations! Your bot is now active and ready to take orders!
How to use your bot
Send a message to your own number (or any connected number) to start logging.
Sample Text Message:
"I had lunch for 25 thousand"
"Buy gasoline 50k and credit 10k"
"Payday came in at 5,000,000 yesterday"
"Pay for parking 2000"
Examples of Special Commands:
/help- Display help info./total- Display the financial summary./list- Displays the last few transactions./delete 5- Delete transaction number 5.
Image Process Example: Simply send a photo of your receipt, bill, or invoice. The bot will try to read it automatically!
Structure of the Result Spreadsheet
Your data will be neatly organized in Google Sheets with the following columns:
| Date | Amount | Category | Description | User ID | Timestamp |
| 2025-04-03 | -80000 | Transportation | Car wash | 1278870305 | 2025-04-03 15:10:31 |
| 2025-04-03 | -17000 | Food | Eat mixed tofu | 1278870305 | 2025-04-03 15:21:10 |
Having trouble? Check this part!
If you encounter any problems, try checking some of the following common things:
- "Missing required environment variable": Make sure all variables in the file
.envhas been filled in correctly. - "Error initializing Google Sheets": Check if the file
credentials.jsonis correctly located and whether service account- it already has Editor access to your spreadsheets. - "QR code not appearing": Ensure a stable internet connection and try restarting the bot.
- "Gemini API error": Verify your Gemini API Key again.
That's it, now you have a 24/7 personal finance assistant in your pocket. Good luck, and may your financial management become easier and more enjoyable!


