Skip to content

Spidy20/Telegram_Chatgpt_Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create Telegram Chatbot💬 using ChatGPT, Flask, and EC2

forthebadge made-with-python Python 3.8

YouTube Thumbnail

Overview

This project demonstrates how to create a Telegram chatbot using ChatGPT, Flask, and EC2. The following technologies and services are used:

  • Ngrok and Flask as a server.
  • Telegram BOT Token obtained from "BotFather".
  • ChatGPT API for generating responses.
  • Flask App as an API for the Request/Response model.
  • AWS EC2 for deployment (24/7 running).

Steps

  1. Create free accounts on OpenAI, AWS, and Ngrok.
  2. Create a Flask App.
  3. Create an EC2 instance on AWS.
  4. Git clone this repository on the EC2 instance.
  5. Create a Telegram bot using "BotFather" and obtain the API Token.
  6. Use the TELEGRAM_BOT_TOKEN and OPENAI_API_KEY in your code (avoid using static values, use global variables).
  7. Run the script on the EC2 instance.
  8. Open a second terminal and use Ngrok to create a tunnel on port 5000.
  9. Set up a webhook for Telegram verification.

Usage

To use this project:

  1. Clone the repository.

  2. Open a terminal in the working directory.

  3. Run the following command to install the required dependencies:

    pip install -r requirements.txt
    
  4. telegram_bot.py is the Flask API that handles the request/response of the chatbot.

  5. Run the script with the following command:

    python3 telegram_bot.py
    
  6. To set up the webhook, use the following format:

    https://api.telegram.org/bot<Your Bot Token>/setWebhook?url=<URL of App>
    

For a more detailed explanation of this project, refer to the tutorial on the Machine Learning Hub YouTube channel.

Screenshots

Support

If you find this project helpful, consider supporting me:

Feel free to follow me and star⭐ this repository!

About

- Implementation of Telegram ChatGPT Bot using Python, Flask, Ngrok.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages