A Golang Telegram bot powered by Google's free Gemini
LLM API
This Telegram bot uses Google's Gemini API to provide an AI assistant experience via Telegram. It is written in Golang.
- Chat with an AI assistant (powered by
Google Gemini
) on Telegram - Support both
gemini-pro
andgemini-pro-vision
models
(Thegemini-pro-vision
model is not optimized for multi-turn conversations) - Restrict bot access to authorized users
- Google Gemini API key
Use your Google account to create your API key. - Telegram bot token
Create a bot from Telegram @BotFather and obtain an access token.
The bot is configured via environment variables or a .env
file:
BOT_TOKEN = your_telegram_bot_token
GEMINI_API_KEY = your_google_gemini_key
ALLOWED_USERS = username1,username2 # Optional, restrict bot access
See .env.example for an example. Just copy or rename it to .env
- Pre-built images are available on GitHub Container Registry:
docker pull ghcr.io/hkint/go-gemini-telegram-bot:latest
- Use Docker-Compose
See compose.yaml for details.
docker-compose up -d
-
Install Go dependencies (Go version: 1.20 or higher)
go mod tidy
-
Set environment variables (or use
.env
file, you can copy it from.env_example
)export BOT_TOKEN='your_telegram_bot_token' export GEMINI_API_KEY='your_google_gemini_key'
-
Run the bot
go run main.go
This project is licensed under the MIT License - see the LICENSE file for details.