Quick Start Guide
This guide will get you from zero to a running Telegram bot with AI responses in under 5 minutes using Docker.Prerequisites
Before starting, ensure you have:- Docker and Docker Compose installed
- A Telegram account to create a bot
- An OpenRouter account for AI responses (free tier available)
If you don’t have Docker installed, see the Installation Guide for detailed setup instructions.
Step 1: Clone the Repository
Step 2: Get Your API Keys
Create a Telegram Bot
Open Telegram and start a chat with @BotFather:Follow the prompts to:
- Choose a name for your bot (e.g., “My AI Assistant”)
- Choose a username (must end in
bot, e.g.,my_ai_assistant_bot) - Copy the bot token that BotFather provides
Get OpenRouter API Key
- Visit OpenRouter.ai
- Sign up for a free account
- Navigate to Keys section
- Click Create Key and copy the generated key
OpenRouter provides free access to several AI models. The default configuration uses
tngtech/deepseek-r1t2-chimera:free.Step 3: Configure Environment Variables
Create a.env file in the project root:
.env file with your actual values:
.env
Configuration Options Explained
| Variable | Description | Default | Required |
|---|---|---|---|
DB_USER | PostgreSQL username | postgres | Yes |
DB_PASSWORD | PostgreSQL password | - | Yes |
TELEGRAM_BOT_TOKEN | Your bot token from @BotFather | - | Yes |
OPENROUTE_KEY | OpenRouter API key | - | Yes |
AI_SYSTEM_PROMPT | AI personality/behavior instructions | Chaotic Spanish AI | No |
AI_TEMPERATURE | Response creativity (0.1-2.0) | 1.2 | No |
AI_MAX_TOKENS | Maximum response length | 150 | No |
JWT_SECRET | Secret for signing auth tokens | - | Yes |
Step 4: Launch with Docker Compose
Start all services with a single command:The first build takes 2-3 minutes as Maven downloads dependencies and compiles the application. Subsequent starts are much faster.
Step 5: Verify the Application
Access Swagger UI
Open your browser and navigate to:http://localhost:8080/swagger-ui.htmlYou should see the interactive API documentation with all available endpoints.
Step 6: Create Your First User
Register a user to access the API:Step 7: Authenticate and Get Token
Login to receive a JWT token:Step 8: Test the Telegram Bot
Find Your Bot on Telegram
Open Telegram and search for the username you chose during bot creation (e.g.,
@my_ai_assistant_bot)Start a Conversation
Send a message to your bot:The bot should respond with an AI-generated message within a few seconds.
Step 9: Send a Proactive Message
Now send a message FROM the API TO Telegram:Using Swagger UI (Alternative)
You can also test the API through the interactive documentation:Open Swagger UI
Navigate to http://localhost:8080/swagger-ui.html
Authenticate
- Click the Authorize button (top right)
- Enter your token in the format:
Bearer YOUR_TOKEN_HERE - Click Authorize then Close
Architecture at Runtime
Here’s what happens when you send a Telegram message:Stopping the Application
To stop all containers:Next Steps
View Logs
Customize AI Behavior
Edit
AI_SYSTEM_PROMPT in .env to change your bot’s personalityExplore API Endpoints
Check out all available endpoints in Swagger UI at
/swagger-ui.htmlLocal Development
Set up the project for local development without Docker
Troubleshooting
Bot doesn't respond to messages
Bot doesn't respond to messages
- Check application logs:
docker-compose logs -f app - Verify
TELEGRAM_BOT_TOKENin.envis correct - Ensure the bot is not already running elsewhere (only one instance can poll)
- Check that Telegram user started the bot (sent
/startor any message)
Database connection errors
Database connection errors
- Verify
DB_PASSWORDmatches in.env - Check database health:
docker-compose ps - Wait for database to become healthy (check logs:
docker-compose logs db)
AI responses fail
AI responses fail
- Verify
OPENROUTE_KEYis valid - Check OpenRouter account has credits/quota
- Review app logs for specific API errors
Port 8080 already in use
Port 8080 already in use
Edit
docker-compose.yml to change the port mapping:For more detailed installation options and local development setup, see the Installation Guide.