Giter VIP home page Giter VIP logo

chatgpt-telegram-bot-serverless's Introduction

ChatGPT Telegram Bot in AWS Lambda

This a Telegram bot that lets you chat with ChatGPT. This bot is created using the brand new ChatGPT API. The Telegram bot is deployed in completely serverless in AWS Lambda. No need to setup a local server or do login in the browser.

Features

  • New ChatGPT API support. ๐Ÿง 
  • Voice messages support! ๐Ÿ”ฅ
  • Markdown rendering support.

Initial Setup

  1. Create an OpenAI account and get an API Key.
  2. Create an AWS account.
  3. Setup your Telegram bot. You can follow this instructions to get your token.
  4. Get your internal session token for ChatGPT:
  • For this go to ChatGPT
  • Press F12, click on session and copy the contents of __Secure-next-auth.session-token.
[](/img/session_token.png)
  1. To enable support for voice messages you need to create a S3 bucket in your AWS account.
  • Go to the top search bar and write S3.
[](/img/s3_browser.png)
  • Click the Create Bucket button.
[](/img/create_bucket_button.png)
  • Configure the creation of your bucket. The name must be unique worldwide. Scroll to bottom and click Create Bucket and don't change any other configuration.
[](/img/create_bucket_config.png)
  1. Go to .chalice/config.json and stablish the configurations:
  • TELEGRAM_TOKEN with your Telegram token.
  • OPENAI_API_KEY with the value of your Open AI API Token.
  • VOICE_MESSAGES_BUCKET with the bucket name you created previously.

Installation

  1. Install Python using pyenv or your prefered Python installation.
  2. Create a virtual environment: python3 -m venv .venv.
  3. Activate you virtual environment: source .venv/bin/activate.
  4. Install dependencies: pip install -r requirements.txt.
  5. Install the AWS CLI and configure your credentials.

Deployment

  1. Run chalice deploy.
  2. Go to the AWS Console -> Lambda -> chatgpt-telegram-bot-dev-message-handler-lambda -> Configuration -> Function URL.
  3. Click Create Function URL and set Auth type to NONE.
  4. Copy the created function URL.
  5. Stablish your Telegram webhook to point to you AWS Lambda running curl --request POST --url https://api.telegram.org/bot<YOUR_TELEGRAM_TOKEN>/setWebhook --header 'content-type: application/json' --data '{"url": "<YOUR_FUNCTION_URL"}'

Great! Everything is setup :) Now go to Telegram and find your bot name and use ChatGPT from there!

Coming soon!

  • Decoupled Token refresh in conversation.
  • Increase response performance.
  • Error handling from ChatGPT services.
  • Deploy solution with one-click using CloudFormation.

Credits

chatgpt-telegram-bot-serverless's People

Contributors

franalgaba avatar yanshibin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.