{"id":21319002,"url":"https://github.com/emingenc/telegramgpt","last_synced_at":"2025-10-17T06:01:15.676Z","repository":{"id":185296136,"uuid":"628600874","full_name":"emingenc/telegramGPT","owner":"emingenc","description":"step-by-step guide on creating your very own AI bot using Python, Telegram, and OpenAI GPT models.","archived":false,"fork":false,"pushed_at":"2024-10-28T07:02:35.000Z","size":72,"stargazers_count":18,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-28T08:55:54.360Z","etag":null,"topics":["chatbot","gpt-4","langchain","langgraph","langgraph-python","openai","python3","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emingenc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-16T13:13:44.000Z","updated_at":"2024-10-28T07:02:38.000Z","dependencies_parsed_at":"2023-08-01T11:54:41.528Z","dependency_job_id":null,"html_url":"https://github.com/emingenc/telegramGPT","commit_stats":null,"previous_names":["emingenc/telegramgpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emingenc%2FtelegramGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emingenc%2FtelegramGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emingenc%2FtelegramGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emingenc%2FtelegramGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emingenc","download_url":"https://codeload.github.com/emingenc/telegramGPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225791365,"owners_count":17524771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","gpt-4","langchain","langgraph","langgraph-python","openai","python3","telegram-bot"],"created_at":"2024-11-21T19:31:17.202Z","updated_at":"2025-10-17T06:01:15.536Z","avatar_url":"https://github.com/emingenc.png","language":"Python","readme":"# Create Your Own ChatGPT on Telegram: A Step-by-Step Guide to Building a Python-powered AI Bot\n\n## Introduction\n\nAre you tired of using the same AI-powered chatbots available on the market? Do you want to build your own chatbot and customize it to your liking? Then, look no further! In this blog post, we'll walk you through a step-by-step guide on creating your very own AI bot using Python, Telegram, and OpenAI GPT models. Get ready to unleash the power of artificial intelligence right at your fingertips!\n\nwhen you change models at conf.py be sure start new evctordb since vector dimension is different for each model.\n\n## Router  usage\n\nyou can give any llm in routes.py file.\n\nYou can add any additional llm to the routes.py file. \n\n![telegramgpt_llm_router](https://github.com/user-attachments/assets/ff5af371-d23b-408f-981f-678f5ad5ac50)\n\n\n\n\n## Quick start\n\n### Prerequisites\n\n- A Telegram account\n- A Telegram bot API token (you can get one from the BotFather bot on Telegram)\n- An OpenAI API key (you can get one by signing up on the OpenAI website)\n- make sure you added your username env file\n- Docker and docker-compose\n\n### Steps\n\n1. Clone the repository:\n\n```bash\ngit clone --recursive https://github.com/emingenc/telegramGPT.git\ncd telegramGPT\n```\n\n2. Set up environment variables create .env file\n    \n    ```bash\n    TELEGRAM_TOKEN=\"your telegram token\"\n    OPENAI_API_KEY=\"your openai api key\"\n    BOTNAME=\"your bots name\"\n    TAVILY_API_KEY=\"tav api key\"\n    USERS=allowed users\n    ANTHROPIC_API_KEY=\"anthropic api key\"\n\n    ```\n\n3. Run the bot using docker-compose:\n    \n    ```bash\n    docker-compose up\n    ```\n\n\n\n## Step 1: Setting up your Telegram bot\n\nBefore diving into the code, you'll need to create a new bot on Telegram. Follow these simple steps:\n\n1. Open the Telegram app and search for the \"BotFather\" bot.\n2. Start a chat with BotFather and send the command \"/newbot\" to create a new bot.\n3. Choose a name and username for your bot. BotFather will provide you with a unique API token, which you'll need later. Save it somewhere safe.\n\n## Step 2: Cloning the code repository\n\nClone the code repository from GitHub using the following command:\n\n```bash\ngit clone --recursive https://github.com/emingenc/telegramGPT.git\ncd telegramGPT\n```\n\n## Step 3: Installing the dependencies  \n\nInstall the required dependencies using the following command:\n\n```bash\npip3 install -r requirements.txt\n```\n\n## Step 4: Exploring the code\n\nIn our project, we have four main files:\n\n1. telegram_bot.py: The main script that handles the Telegram bot's functionality.\n2. gpt_message_handler.py: Contains functions for interacting with OpenAI's GPT models and managing chat history.\n3. conf.py: A configuration file to store the list of allowed users.\n4. requirements.txt: Lists the required Python libraries for the project.\n\n## Step 5: Configuring the bot\n\nEdit conf.py to add the usernames of users allowed to interact with your bot. For example:\n\n\n``` python\nusers = [\"your_telegram_username\"]\n```\n\n## Step 6: Setting up the environment variables\n\n\nYou need to set up environment variables: TELEGRAM_TOKEN (the API token you received from BotFather) and OPENAI_API_KEY (your OpenAI API key). BOTNAME (name of bot)\nYou can either add them to your system's environment variables or use a .env file. \n\n## Step 7: Running the bot\n\nStart your bot by running the telegram_bot.py script:\n\n```bash\npython3 telegram_bot.py\n```\n\nYour bot is now up and running! Start a chat with your Telegram bot and see it in action.\n\n## Conclusion\n\nCongratulations! You've just built your own chatbot using Python, Telegram, and OpenAI GPT models. Now you can enjoy the power of AI through a personalized, engaging chat experience on Telegram. Don't forget to share your thoughts and experiences in the comments below. Happy coding!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femingenc%2Ftelegramgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femingenc%2Ftelegramgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femingenc%2Ftelegramgpt/lists"}