https://github.com/fivlas/telegram-selfbot
A Telegram self-bot powered by GPT-4o that automatically responds to private messages using OpenAI.
https://github.com/fivlas/telegram-selfbot
ai selfbot telegram typescript
Last synced: about 2 months ago
JSON representation
A Telegram self-bot powered by GPT-4o that automatically responds to private messages using OpenAI.
- Host: GitHub
- URL: https://github.com/fivlas/telegram-selfbot
- Owner: Fivlas
- Created: 2025-02-19T17:34:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-19T17:53:10.000Z (over 1 year ago)
- Last Synced: 2025-02-19T18:33:34.509Z (over 1 year ago)
- Topics: ai, selfbot, telegram, typescript
- Language: TypeScript
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Telegram Self-Bot with OpenAI
A Telegram self-bot powered by GPT-4o that automatically responds to private messages using OpenAI.
## Features
- Automatically responds to private messages
- Uses GPT-4o for intelligent conversations
- Secure authentication using Telegram's API
- Stores message history per user
## Setup & Installation
### 1. Clone the Repository
```sh
git clone https://github.com/yourusername/telegram-selfbot.git
cd telegram-selfbot
```
### 2. Install Dependencies
```sh
npm install
```
### Fill a .env File
Create a `.env` file in the project root and add the following environment variables:
```sh
TELEGRAM_SESSION=your_telegram_session_string
APP_ID=your_telegram_app_id
API_HASH=your_telegram_api_hash
OPENAI_API_KEY=your_openai_api_key
```
How to get these values?
- Get your `APP_ID` and `API_HASH` from my.telegram.org
- Generate a `TELEGRAM_SESSION` using telegram.sessions.StringSession
- Get an `OPENAI_API_KEY` from OpenAI
### Running the Bot
To start the bot, run:
```sh
npx tsx index.ts
```
### First-Time Setup
On the first, the bot will ask for:
- Your **phone number** (linked to your Telegram account)
- Your **Telegram login code** (sent via Telegram)
- Your **Telegram password** (if 2FA is enabled)
Once logged in, the bot will start listening for private messages and responding automatically.
### How It Works
1. The bot listens for **new private messages**.
2. It stores **message history per user**.
3. It sends user messages to **OpenAI's GPT-4o**.
4. The AI-generated response is **sent back to the user**.