Initial Telegram AI bot
This commit is contained in:
commit
2f88229a1f
8 changed files with 1047 additions and 0 deletions
86
README.md
Normal file
86
README.md
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# Marvin Telegram Bot
|
||||
|
||||
Simple Telegram bot server that sends your Telegram messages to Gemini and replies back. OpenRouter can be configured as a fallback. Recent conversation memory is stored persistently in SQLite.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Copy the environment file:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Edit `.env` and add:
|
||||
|
||||
```env
|
||||
TELEGRAM_BOT_TOKEN=...
|
||||
GEMINI_API_KEY=...
|
||||
OPENROUTER_API_KEY=...
|
||||
```
|
||||
|
||||
Gemini is the primary provider. OpenRouter is optional, but useful as fallback.
|
||||
|
||||
Get keys from:
|
||||
|
||||
```text
|
||||
https://aistudio.google.com/app/apikey
|
||||
https://openrouter.ai/keys
|
||||
```
|
||||
|
||||
3. Define the bot personality in `personality.md`.
|
||||
|
||||
Examples:
|
||||
|
||||
```text
|
||||
You are Marvin, a funny, slightly sarcastic assistant. Keep replies short and playful.
|
||||
```
|
||||
|
||||
```text
|
||||
You are Marvin, a melancholic but kind assistant. Speak poetically, but stay useful.
|
||||
```
|
||||
|
||||
```text
|
||||
You are Marvin, a calm technical assistant. Be direct, precise, and avoid jokes.
|
||||
```
|
||||
|
||||
Optional settings in `.env`:
|
||||
|
||||
```env
|
||||
GEMINI_MODEL=gemini-2.5-flash-lite
|
||||
OPENROUTER_MODEL=mistralai/mistral-small-3.2-24b-instruct:free
|
||||
PERSONALITY_FILE=personality.md
|
||||
MEMORY_DB=marvin.sqlite
|
||||
MAX_HISTORY_MESSAGES=20
|
||||
```
|
||||
|
||||
## Memory
|
||||
|
||||
Marvin stores chat messages and long-term memories in SQLite at `marvin.sqlite` by default.
|
||||
|
||||
The AI receives:
|
||||
|
||||
- the most recent `MAX_HISTORY_MESSAGES` chat messages
|
||||
- all long-term memories for the current Telegram chat
|
||||
|
||||
Recent chat history commands:
|
||||
|
||||
```text
|
||||
/forget
|
||||
```
|
||||
|
||||
Long-term memory commands:
|
||||
|
||||
```text
|
||||
/remember location = Zagreb
|
||||
/memories
|
||||
/forget_memory location
|
||||
/forget_memories
|
||||
```
|
||||
|
||||
4. Start the bot:
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
Then open Telegram and message your bot.
|
||||
Loading…
Add table
Add a link
Reference in a new issue