A simple Amazon price tracking bot written in Python by Leixien
Brief description of the code
This Telegram Bot checks the price of a given Amazon Product.
- You can save the product and check the price when you want with a single tap.
- You can check the prices of different amazon store states by sending the link of the product itself
- NEW! π Automatic Amazon affiliate link conversion
- NEW! π Track your conversion statistics
- NEW! π Daily reminders at 11:00 and 16:00 (Italy time)
- NEW! π€ AI-powered product advisor (Ollama local AI)
- NEW! ποΈ Optional Supabase database for analytics
- Join my discord :)
- Find a new song (try it <3 )
The modules I used are:
- BeautifulSoup (BS4) - to scrap Amazon website
- Telegram API - for Bot API
I created 3 files to make the code clear and readable!
In the files You will find:
- main.py - Main code whit Telegram API
- myFunctions.py - Functions implements for manipulate the data and
- scraper.py - Scraper Amazon site with BeautifulSoup
Simply send any Amazon.it link to the bot and it will automatically reply with the affiliate version!
Supported formats:
https://www.amazon.it/dp/B08N5WRWNW/https://www.amazon.it/product-name/dp/B08N5WRWNW/https://amazon.it/gp/product/B08N5WRWNWhttps://amzn.eu/d/XXXXX(short links)
Manually convert an Amazon link to affiliate link.
Example:
/convertlink https://www.amazon.it/dp/B08N5WRWNW/
View your conversion statistics (today and total).
Disable daily reminders.
Re-enable daily reminders.
The bot sends automatic reminders at 11:00 and 16:00 (Italy time) to all subscribed users!
The bot includes an intelligent AI assistant powered by Ollama (local AI on Raspberry Pi):
- π‘ Smart product recommendations based on your requests
- π Product comparisons (e.g., "iPhone 15 vs Samsung S24")
- π° Budget-based suggestions (e.g., "laptop gaming under 1000β¬")
- π― Personalized advice tailored to your needs
- π 100% FREE - runs locally on Raspberry Pi, no API costs!
Simply ask the bot for product advice in natural language:
Examples:
"Mi consigli un laptop per gaming sotto 1000β¬?"
"Quale Γ¨ il miglior smartphone con fotocamera?"
"Confronta iPhone 15 vs Samsung S24"
"Ho bisogno di cuffie wireless per correre"
"Cerco una friggitrice ad aria buona"
The bot will:
- π§ Analyze your request with AI
- π‘ Generate personalized recommendations
- π Provide affiliate Amazon links automatically
Show detailed AI assistant help and examples.
The AI runs locally on Raspberry Pi using Ollama (free, open-source).
# On Raspberry Pi
chmod +x scripts/setup_raspberry_ollama.sh
./scripts/setup_raspberry_ollama.shThe script will:
- β Install Ollama
- β Download AI model (Mistral 7B / LLaMA 3.2)
- β Configure the service
- β Test the installation
Full guide: See docs/SETUP_AI.md
- Raspberry Pi 4/5 with 4GB RAM (for Mistral 7B)
- Raspberry Pi 4 with 2GB RAM (for LLaMA 3.2 3B)
- Raspberry Pi 3 with 2GB RAM (for LLaMA 3.2 1B)
- Raspberry Pi OS (64-bit)
No problem! The bot works perfectly even without AI. Simply set in .env:
AI_ENABLED=falsepip install -r requirements.txtCreate a .env file from the template:
cp .env.example .envEdit .env and add your bot token:
BOT_TOKEN=your_telegram_bot_token_here
Edit config.py and set your Amazon affiliate tag:
AFFILIATE_TAG = "your-tag-21"python main.pyTrackerPriceAmazon-Bot/
βββ main.py # Main bot with command handlers
βββ scraper.py # Amazon scraper for prices
βββ myFunctions.py # Utility functions
βββ config.py # Configuration (affiliate tag, timezones, AI, etc.)
β
βββ handlers/
β βββ amazon_affiliate.py # Affiliate link conversion logic
β βββ ai_assistant.py # AI product advisor (NEW)
β
βββ utils/
β βββ user_manager.py # User tracking for reminders
β βββ scheduler.py # Daily reminder scheduler
β βββ ollama_client.py # Ollama AI client (NEW)
β βββ supabase_manager.py # Supabase database (NEW, optional)
β
βββ data/
β βββ users.json # User database for broadcast
β βββ stats.json # Conversion statistics
β
βββ docs/
β βββ SETUP_AI.md # AI setup guide (NEW)
β βββ SETUP_SUPABASE.md # Supabase setup guide (NEW)
β
βββ scripts/
βββ setup_raspberry_ollama.sh # Ollama auto-install script (NEW)
I will try to add some new features every month to make this bot useful Some features I will improve in the next month:
- β
Schedulable Messages for price alert(DONE - Daily reminders implemented!) - β
AI-powered product recommendations(DONE - Ollama AI integrated!) - Amazon Product API integration for real product search
- A graphic with the price of the product
- Inline mode for SuperGroups
- Price drop notifications
- Multi-language support (EN/IT/ES)