Skip to main content

Overview

The Price Tracker Bot is a Telegram bot that monitors Amazon product prices and sends you notifications when prices drop. This guide will help you get the bot running and tracking your first product.
1
Create a Telegram Bot
2
Before you can run the bot, you need to create it with BotFather:
3
  • Open Telegram and search for @BotFather
  • Start a chat and send /newbot
  • Follow the prompts to choose a name and username for your bot
  • BotFather will give you a bot token - save this for later
  • 4
    Your bot token looks like this: 123456789:ABCdefGhIjKlmNoPQRsTUVwxyZKeep it secret! Anyone with this token can control your bot.
    5
    Clone and Install
    6
    Download the bot code and install its dependencies:
    7
    git clone https://github.com/your-username/price-tracker-bot.git
    cd price-tracker-bot
    npm install
    
    8
    This installs all required packages including:
    9
  • node-telegram-bot-api - Telegram bot integration
  • playwright - Web scraping engine
  • node-cron - Automated price checking
  • dotenv - Environment configuration
  • 10
    Playwright will download Chromium browser (~100MB) during installation. This is normal and required for price scraping.
    11
    Configure Your Bot Token
    12
    Create a .env file in the project root and add your bot token:
    13
    TELEGRAM_TOKEN=your_bot_token_here
    
    14
    Terminal
    # Create .env file quickly
    echo "TELEGRAM_TOKEN=123456789:ABCdefGhIjKlmNoPQRsTUVwxyZ" > .env
    
    .env
    TELEGRAM_TOKEN=123456789:ABCdefGhIjKlmNoPQRsTUVwxyZ
    
    15
    Start the Bot
    16
    Launch the bot with:
    17
    npm start
    
    18
    You should see:
    19
    ✅ Datos cargados. Productos: 0, Chats: 0
    🚀 Bot iniciado. Esperando comandos...
    
    20
    The bot runs in watch mode, so it will automatically restart when you modify the code.
    21
    Start Using the Bot
    22
    Open Telegram and find your bot by searching for its username. Send the /start command:
    23
    /start
    
    24
    You’ll receive a welcome message with all available commands:
    25
    🤖 ¡Hola! Soy tu bot rastreador de precios.
    
    *Comandos:*
    📦 /add [url] - Añadir producto
    🔍 /check - Revisar precios ahora
    📝 /list - Ver productos en seguimiento
    🗑️ /remove [url] - Eliminar producto
    ✏️ /edit [url_actual] [url_nueva] - Actualizar URL del producto
    📊 /stats - Ver estadísticas
    📈 /chart [url] - Ver gráfico del historial
    ❓ /help - Mostrar ayuda
    
    26
    Track Your First Product
    27
    Copy any Amazon product URL and send it with the /add command:
    28
    /add https://www.amazon.com/dp/B08N5WRWNW
    
    29
    The bot will:
    30
  • Scrape the product page for title, price, and image
  • Save it to prices.json
  • Start monitoring it for price changes
  • 31
    The bot sanitizes URLs by removing tracking parameters and query strings. It stores products by their clean URL (e.g., https://www.amazon.com/dp/B08N5WRWNW).
    32
    You’ll receive a confirmation:
    33
    ✅ Producto agregado exitosamente
    
    📦 [Product Title]
    💰 Precio actual: $XX.XX
    📅 Agregado: [Date]
    
    🔔 Te notificaré cuando baje el precio.
    

    How Price Monitoring Works

    Once you’ve added products, the bot automatically:

    Every 2 Hours

    Checks all tracked products for price changes using the automated cron job defined in index.mjs:732

    Daily at 20:00

    Sends you a summary of all tracked products with interactive buttons to view details

    Instant Alerts

    Notifies you immediately when any product’s price drops below its previous recorded price

    Price History

    Stores up to 120 price points per product for historical analysis and charting

    Example: Price Drop Notification

    When a price drops, you’ll receive:
    🚨 ¡Precio reducido!
    
    *[Product Title]*
    
    💰 Precio anterior: $99.99
    🎯 Precio actual: $79.99
    💵 Ahorro: $20.00 (20.0% menos)
    📉 Histórico más bajo: $79.99
    
    [Ver en Amazon](url)
    

    Quick Commands Reference

    CommandDescriptionExample
    /add [url]Track a new product/add https://amazon.com/dp/B08N5WRWNW
    /listView all tracked products/list
    /checkForce price check now/check
    /remove [url]Stop tracking a product/remove https://amazon.com/dp/B08N5WRWNW
    /statsView tracking statistics/stats
    /chart [url]View price history chart/chart https://amazon.com/dp/B08N5WRWNW

    Data Storage

    The bot stores all data in prices.json in the project root:
    {
      "products": {
        "https://www.amazon.com/dp/XXXXX": {
          "url": "https://www.amazon.com/dp/XXXXX",
          "title": "Product Name",
          "price": 79.99,
          "lowestPrice": 79.99,
          "imageUrl": "https://...",
          "addedDate": "2024-03-10T...",
          "lastChecked": "2024-03-10T...",
          "history": [
            {"date": "2024-03-10T...", "price": 99.99},
            {"date": "2024-03-10T...", "price": 79.99}
          ]
        }
      },
      "chats": [123456789]
    }
    
    You can backup prices.json to preserve your tracking history. The bot creates it automatically if it doesn’t exist.

    Next Steps

    Installation Details

    Learn about system requirements and advanced configuration

    View Source Code

    Explore the code on GitHub

    Troubleshooting

    Make sure:
    1. The bot is running (npm start in terminal)
    2. You sent /start to register your chat
    3. The TELEGRAM_TOKEN is correct in .env
    You need to create a .env file with your bot token:
    echo "TELEGRAM_TOKEN=your_token_here" > .env
    
    Then restart the bot.
    This can happen if:
    • Amazon changed their page structure
    • The URL is invalid
    • Network/firewall blocking Playwright
    Try with a different Amazon product URL. The scraper uses multiple CSS selectors defined in index.mjs:80-109.
    Playwright needs to download Chromium. If it fails:
    # Install Playwright browsers manually
    npx playwright install chromium
    

    Build docs developers (and LLMs) love