A powerful Telegram bot powered by Google's Gemini 2.0 Flash for natural conversations and stunning AI image generation with multimodal capabilities.
- Advanced Image Generation: Create stunning images using Gemini 2.0 Flash's native image generation capabilities
- Consistent character and setting representation across multiple generated images
- Superior text rendering in generated images
- Conversational image editing through natural dialogue
- Accurate representation of complex concepts using world knowledge
- Natural Conversation: Engage in fluid, context-aware conversations with Gemini AI
- Image Analysis: Send any image for AI-powered analysis and insights
- Smart History: Maintains chat history for more contextual responses
- True Multi-Modal Interaction: Seamlessly process text and images in the same conversation
Generate consistent visual narratives where characters and settings remain cohesive throughout multiple images.
Fine-tune generated images through natural conversation, allowing for precise adjustments and creative exploration.
Create detailed, accurate images backed by Gemini's understanding of real-world concepts - perfect for technical illustrations or educational content.
Generate images with crisp, accurate text rendering - ideal for creating:
- Social media posts
- Advertisements
- Event invitations
- Infographics
- Node.js (v18 or newer)
- A Telegram Bot Token from @BotFather
- A Google Gemini API Key from Google AI Studio
-
Clone & Install
git clone https://github.com/jiaweing/GeminiTelegramBot cd GeminiTelegramBot pnpm install -
Configure Environment
cp .env.example .env
Edit
.envwith your tokens:BOT_TOKEN=your_telegram_bot_token GEMINI_API_KEY=your_gemini_api_key
-
Start the Bot
pnpm dev
/start- Initialize or reset the bot/help- View usage instructions/clear- Clear conversation history- Type
clear- Alternative way to reset chat
-
Storytelling
generate: Tell a story about a cute baby turtle's adventure with illustrations in 3D digital art style -
Iterative Design
generate: A cozy coffee shop interior [Then refine with]: Make it more modern with large windows [And further]: Add some plants and wooden elements -
Technical Visualization
generate: Step-by-step illustration of how a solar panel works -
Text-Rich Images
generate: Create a modern event poster for a tech conference with the title "Future of AI 2025" and all the important details
- Send any image with prompts like:
- "What's unique about this architectural style?"
- "Can you analyze the composition of this photograph?"
- "What emotions does this artwork convey?"
- "Explain quantum computing with visual examples"
- "Design a logo for an eco-friendly startup"
- "Create a visual story about space exploration"
graph TD
A[User Input] --> B[Telegram Bot]
B --> C{Input Type}
C -->|Text| D[Text Processing]
C -->|Image| E[Image Analysis]
C -->|Generate| F[Gemini 2.0 Flash]
D --> G[Gemini AI]
E --> G
F --> G
G --> H[Response Handler]
H --> I[Chat History]
H --> J[File System]
H --> K[User Response]
- Framework: Telegraf for Telegram Bot API
- AI Engine: @google/genai for Gemini integration
- Uses Gemini 2.0 Flash experimental model for enhanced image generation
- Language: TypeScript for type safety and better development experience
- Runtime: Node.js with support for modern ES modules
The bot includes comprehensive error handling for:
- Network connectivity issues
- API rate limits and timeouts
- Invalid input formats
- File system operations
- AI processing errors
Contributions are welcome! Please feel free to submit a Pull Request.
MIT