System Requirements
Before installing the Price Tracker Bot, ensure your system meets these requirements:Node.js
Version 16.0.0 or higherRequired for running the bot server and dependencies
npm
Version 7.0.0 or higherPackage manager (installed with Node.js)
Disk Space
~150 MB freeFor dependencies and Chromium browser
Operating System
Linux, macOS, or WindowsPlaywright supports all major platforms
Check Your Environment
Verify Node.js and npm are installed:Installation Steps
Playwright will automatically download a Chromium browser (~100MB) during installation. This is required for scraping Amazon product pages.
Getting Your Telegram Bot Token
- Open Telegram and search for @BotFather
- Send
/newbotto create a new bot - Choose a name (e.g., “My Price Tracker”)
- Choose a username (e.g., “my_price_tracker_bot”)
- Copy the token BotFather provides
ℹ️ No existe prices.json — se creará al guardar.
✅ Datos cargados. Productos: 0, Chats: 0
🚀 Bot iniciado. Esperando comandos...
Project Structure
Understanding the bot’s file structure:Key Files
index.mjs - Main Application
index.mjs - Main Application
The core bot logic written in ES modules:See
- Lines 1-50: Configuration, imports, and data loading
- Lines 52-136: Scraping engine with multiple CSS selectors
- Lines 138-250: Price checking and notification logic
- Lines 252-333: Chart generation using Chart.js
- Lines 335-702: Telegram command handlers
- Lines 704-740: Cron jobs for automation
index.mjs (excerpt)
index.mjs:1-17 for initialization code.prices.json - Data Storage
prices.json - Data Storage
Auto-generated JSON file storing:Managed by
- Product information (title, URL, price)
- Price history (up to 120 data points)
- Registered chat IDs
- Metadata (dates, lowest price)
loadData() and saveData() functions in index.mjs:24-48..env - Environment Variables
.env - Environment Variables
Secure configuration file (not committed to Git):Loaded via
dotenv.config() in index.mjs:8.Configuration Options
Customize bot behavior by editingindex.mjs:
Price Check Frequency
Modify the cron schedule:index.mjs:732-740
Daily Summary Time
Change when daily summaries are sent:index.mjs:719-730
Price History Limit
Adjust how many price points to store:index.mjs:69
Running in Production
Using PM2 Process Manager
For production deployments, use PM2 to keep the bot running:Using Docker
Create aDockerfile:
Dockerfile
Using systemd (Linux)
Create a service file:/etc/systemd/system/price-tracker-bot.service
Troubleshooting Installation
npm install fails
npm install fails
Symptoms: Errors during
npm installSolutions:- Clear npm cache:
- Update npm:
- Check Node.js version:
Playwright installation errors
Playwright installation errors
Symptoms: Chromium download fails or browser not foundSolutions:
- Manual browser install:
- Install system dependencies (Linux):
Ubuntu/Debian
- Check disk space:
TELEGRAM_TOKEN error on startup
TELEGRAM_TOKEN error on startup
Symptoms:
❌ TELEGRAM_TOKEN no definido en .envSolutions:- Verify
.envfile exists:
- Check file contents:
- Ensure no extra spaces:
- Restart the bot:
Bot starts but doesn't respond
Bot starts but doesn't respond
Symptoms: Bot runs but doesn’t reply to commandsSolutions:
-
Check bot token is valid:
- Talk to @BotFather
- Send
/mybots→ select your bot → API Token
- Verify bot is running:
- Check for errors in console output
-
Send
/startto register your chat ID
Scraping fails on all products
Scraping fails on all products
Symptoms: All
/add commands fail with scraping errorsSolutions:- Test browser install:
- Check network connectivity:
- Try with
--no-sandbox(already default in code):
index.mjs:148
- Increase timeout (if network is slow):
index.mjs:75
Permission denied errors
Permission denied errors
Symptoms: Cannot write to
prices.jsonSolutions:- Check file permissions:
- Fix permissions:
- Ensure directory is writable:
Security Considerations
Securing Your Token
Updating Dependencies
Keep packages secure:Performance Tuning
Memory Usage
The bot’s memory footprint:- Base: ~50 MB (Node.js + dependencies)
- Per browser instance: ~100-150 MB
- Peak: ~200 MB during price checks
Optimizing Price Checks
index.mjs:214 for the delay between product checks.
Next Steps
Quickstart Guide
Learn how to use the bot and track your first product
Source Code
Explore the code on GitHub
Getting Help
If you encounter issues:- Check the Troubleshooting section above
- Review console output for error messages
- Ensure all requirements are met
- Open an issue on GitHub with:
- Your Node.js version (
node --version) - Error messages from console
- Steps to reproduce
- Your Node.js version (
For questions about Amazon’s terms of service regarding scraping, review their robots.txt and scraping policies. This bot is for educational purposes.