This Telegram bot allows users to search for eSIM deals based on country, duration (days), and data requirements (GB). The bot interacts with a FastAPI backend, which queries a MongoDB database to provide relevant eSIM options. Users can interact with the bot to specify their criteria, and it will return a list of suitable eSIM deals sorted by price.
First, ensure you have python 3.8 or higher installed. Installed the required dependencies:
-python-telegram-bot
-pycountry
-fastapi
-uvicorn
-pymongo
-requests
-python-dotenv
Run the following command in your terminal:
pip install python-telegram-bot pycountry fastapi uvicorn pymongo requests python-dotenv
To create a bot on Telegram and get your token, follow these steps:
-
Open Telegram and search for BotFather in the search bar.
-
Start a conversation by pressing the
/startbutton. -
Create a new bot by typing
/newbotor selecting the/newbotoption. -
Name your bot when prompted. This will be the display name of your bot.
-
Choose a unique username for your bot, which must end with the word bot (e.g.,
my_bot). -
After completing these steps, you will receive your HTTP API Token. This is your bot's authentication token.
- API_TOKEN: The token you received from BotFather.
- BOT_HANDLE: The username you created for your bot.
Create a .env file in the root of your project and add the following variables:
API_TOKEN=your_telegram_bot_api_token
BOT_HANDLE= @your_telegram_bot_username
FASTAPI_URL=http://localhost:8000
DB_ADDRESS=your_mongodb_connection_stringStart the FastAPI server to handle requests from the bot:
uvicorn app:app --reloadThis will start the FastAPI server on http://localhost:8000 by default.
Once everything is set up, start your Telegram bot by running:
python main.pyYou can now interact with your bot on Telegram. Simply start a conversation with your bot's username and follow the prompts to search for eSIM deals.