{"id":26025431,"url":"https://github.com/iamfoysal/tele_bot","last_synced_at":"2026-04-17T08:32:49.059Z","repository":{"id":280680911,"uuid":"942804285","full_name":"iamfoysal/tele_bot","owner":"iamfoysal","description":"A Telegram bot that integrates OpenAI's GPT-4 for intelligent chat responses, email notifications, and chat history management. Built with Python and the python-telegram-bot library.","archived":false,"fork":false,"pushed_at":"2025-03-04T18:01:48.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T19:19:23.619Z","etag":null,"topics":["aibot","bot","openai","telegram-bot"],"latest_commit_sha":null,"homepage":"https://t.me/dev_ai_agent_bot","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamfoysal.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-04T17:45:55.000Z","updated_at":"2025-03-04T18:04:00.000Z","dependencies_parsed_at":"2025-03-04T19:29:38.606Z","dependency_job_id":null,"html_url":"https://github.com/iamfoysal/tele_bot","commit_stats":null,"previous_names":["iamfoysal/tele_bot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iamfoysal/tele_bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamfoysal%2Ftele_bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamfoysal%2Ftele_bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamfoysal%2Ftele_bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamfoysal%2Ftele_bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamfoysal","download_url":"https://codeload.github.com/iamfoysal/tele_bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamfoysal%2Ftele_bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31921944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aibot","bot","openai","telegram-bot"],"created_at":"2025-03-06T13:48:41.624Z","updated_at":"2026-04-17T08:32:49.041Z","avatar_url":"https://github.com/iamfoysal.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\nThis is a Telegram bot that interacts with users, collects their email addresses, sends a welcome email, and responds to their messages using OpenAI's GPT-4 model. It also maintains a chat history and allows users to clear or view their chat history.\n\nLIVE: [HappyCoder](https://t.me/dev_ai_agent_bot)\n\n### User Commands\n- `/start`: Starts the conversation and prompts the user to enter their email.\n- input your email address: Validates the email format and sends a welcome email. example: `example@gmail.com`\n- `/help`: Displays the help message.\n- `/clear`: Clears the chat history.\n- `/history`: Displays the chat history.\n- Send any message: The bot will respond with an AI-generated text based on the user's input.\n\n\n## Functions\nNote\" Here bot_v2 is the main file of the bot now its updated with the new features and functions.\n### `send_email(receiver_email, username)`\nSends a welcome email to the specified receiver.\n\n**Parameters:**\n- `receiver_email` (str): The email address of the receiver.\n- `username` (str): The username of the receiver.\n\n**Exceptions:**\n- Prints an error message if the email could not be sent.\n\n### `start(update: Update, context: CallbackContext)`\nHandles the `/start` command. Prompts the user to enter their email and initializes the chat history.\n\n**Parameters:**\n- `update` (Update): The update object that contains the message data.\n- `context` (CallbackContext): The context object that contains the bot data.\n\n**Returns:**\n- `ASK_EMAIL`: The next state in the conversation handler.\n\n### `ask_email(update: Update, context: CallbackContext)`\nHandles the user's email input. Validates the email format and sends a welcome email.\n\n**Parameters:**\n- `update` (Update): The update object that contains the message data.\n- `context` (CallbackContext): The context object that contains the bot data.\n\n**Returns:**\n- `ASK_EMAIL`: If the email format is invalid.\n- `ConversationHandler.END`: If the email is valid and the email is sent.\n\n### `get_ai_response(update: Update, context: CallbackContext)`\nHandles incoming messages from the user and responds with AI-generated text. Maintains a chat history and formats the AI response.\n\n**Parameters:**\n- `update` (Update): The update object that contains the message data.\n- `context` (CallbackContext): The context object that contains the bot data.\n\n### `history(update: Update, context: CallbackContext)`\nDisplays the last few messages from the chat history.\n\n**Parameters:**\n- `update` (Update): The update object that contains the message data.\n- `context` (CallbackContext): The context object that contains the bot data.\n\n### `clear_history(update: Update, context: CallbackContext)`\nClears the chat history.\n\n**Parameters:**\n- `update` (Update): The update object that contains the message data.\n- `context` (CallbackContext): The context object that contains the bot data.\n\n### `main()`\nMain function to run the bot. Sets up the application and handlers, and starts polling for updates.\n\n**Execution:**\n- Prints \"🤖 Bot is running...\" to the console.\n- Runs the bot using `app.run_polling()`.\n\n## Environment Variables\nThe following environment variables need to be set in the `.env` file for the bot to function correctly:\n\n- `TELEGRAM_TOKEN`: The token for your Telegram bot.\n- `OPENAI_API_KEY`: The API key for OpenAI.\n- `EMAIL_SENDER`: The email address used to send emails.\n- `EMAIL_PASSWORD`: The password for the email sender account.\n- `BOT_NAME`: The name of the bot (default is \"AI Chatbot\").\n\n### Example `.env` file\n```env\nTELEGRAM_TOKEN=your_telegram_token\nOPENAI_API_KEY=your_openai_api_key\nEMAIL_SENDER=your_email@example.com\nEMAIL_PASSWORD=your_email_password\nBOT_NAME=YourBotName\n```\n\n\n## Setup Telegram Bot\nFirst, create a bot using BotFather on Telegram:\n\n- Start a chat with BotFather (/start).\n- Use the /newbot command to create a bot.\n- Give your bot a name and username.\n- BotFather will provide you with an API Token—save it for later.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamfoysal%2Ftele_bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamfoysal%2Ftele_bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamfoysal%2Ftele_bot/lists"}