This repository contains a simple Telegram bot that utilizes the Amazon Affiliate Program API to automatically generate a product post on your Telegram channel. When an Amazon link is received, the bot fetches product information, an image, and generates a referenced link, then posts this on your Telegram channel.
- Receives Amazon product links
- Fetches product details using Amazon Affiliate Program API
- Posts the product post with information, image and affiliate link to a specified Telegram channel
- Python 3.7+
- Telegram bot token
- Amazon Affiliate Program API credentials (Access Key, Secret Key, Associate Tag)
-
Clone the repository:
git clone https://github.com/Vadilonga/example-amazon-affiliate-telegram-bot.git cd example-amazon-affiliate-telegram-bot
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your variables:
Edit the file
constants.py
in the root of your project directory and add the following:TELEGRAM_TOKEN=your-telegram-bot-token CHANNEL_ID=your-telegram-channel-id AMAZON_ACCESS_KEY=your-amazon-access-key AMAZON_SECRET_KEY=your-your-amazon-secret-key PARTNER_TAG=your-amazon-associate-tag AMAZON_HOST=your-amazon-host AMAZON_REGION=your-amazon-region
-
Run the bot:
python bot.py
- Create a bot on @botfather
- Create a channel on Telegram
- Add the bot as an Administrator in the channel
- Start your bot
- Send an Amazon product link to the bot
- The bot will fetch product details, generate an affiliate link, and post the product information on the specified Telegram channel
Send an Amazon product link like this:
https://www.amazon.com/dp/example-product-id
The bot will respond with a post in your Telegram channel that includes:
- Product title
- Product image
- Product price
- Product old price (if exist)
- Affiliate link to the product
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding! This code was developed exclusively for educational purposes for a university thesis, if you have any questions I will be happy to answer you!