Generate Images on Telegram 🤖🖼️ from Text and Voice using Grok Imagine & Kie AI

Go to Workflow
2 views
Built by Davide Boizza Davide Boizza
Created on June 06, 2026

Description

This workflow creates an AI-powered Telegram bot that allows users to generate and modify images using Grok Imagine models via the Kie AI API.

Key Advantages

1. ✅ Multi-Modal Input Support

Users can interact using:

Text
Voice
Images

This makes the bot highly flexible and user-friendly.

2. ✅ Intelligent AI Orchestration

Instead of directly calling APIs, the workflow uses an AI agent that:

Understands intent
Enhances prompts
Chooses the correct tool automatically

This dramatically improves output quality.

3. ✅ Fully Automated Image Pipeline

From user input to final image delivery:

Upload
Processing
Generation
Result retrieval
Delivery via Telegram

Everything is automated end-to-end.

4. ✅ Asynchronous & Scalable Architecture

The use of:

Webhook callbacks
Wait nodes
Task polling

Prevents timeouts and supports longer image generation tasks.

5. ✅ Secure Access Control

The Telegram ID validation ensures:

Only authorized users can access the workflow.

6. ✅ Modular & Extendable Design

The workflow is built with:

Tool-based architecture
Separate image generation workflows
Clear orchestration logic

This makes it easy to extend with:

Video generation
Style presets
Advanced editing tools
Multi-user support

7. ✅ Production-Ready Structure

The workflow includes:

Error handling guidelines
Structured system prompts
Memory handling
Clear separation of concerns

This makes it suitable for:

Creative agencies
AI SaaS products
Marketing automation
Telegram-based AI services

How it works

This workflow creates a Telegram bot that uses AI to generate and transform images through Grok Imagine models, with support for text, voice, and image inputs.

Telegram Input Handling: Users interact with the bot by sending messages, voice notes, or images. The workflow authenticates users based on their Telegram ID.

Input Processing:
Text messages → Directly sent to the AI agent
Voice messages → Transcribed using OpenAI Whisper, then converted to text
Images → Downloaded from Telegram, uploaded to an FTP server (BunnyCDN), and the public URL is generated

AI Agent Decision Making: The "Grok Imagine Agent" (powered by Grok 4.1 Fast model) analyzes user input and determines whether to:
Generate a new image from text description (text-to-image)
Transform an existing image using a prompt (image-to-image)

Tool Execution: The agent calls specialized workflow tools that trigger image generation via Kie.ai API:
Text-to-Image: Creates images from text prompts using "grok-imagine/text-to-image" model
Image-to-Image: Modifies existing images using "grok-imagine/image-to-image" model

Async Processing: The workflow uses Wait nodes to handle asynchronous image generation, polling Kie.ai for results via task IDs.

Result Delivery: Once images are generated, they're sent back to the user through Telegram messages.

Setup Steps

Telegram Configuration:
Create a Telegram Bot via BotFather to get a bot token
Add your Telegram user ID in the "Code" node (replace XXX)
Configure Telegram credentials in n8n with your bot token

API Credentials:
OpenRouter: Sign up at OpenRouter.ai, get API key for Grok 4.1 Fast access
Kie.ai: Register at Kie.ai for free API key to access image generation models
OpenAI: Set up OpenAI API key for voice transcription (Whisper model)

FTP Server Setup:
Configure FTP server (BunnyCDN recommended) for image hosting
Update FTP credentials in n8n
Set the public URL path in the "Set Image Url" node (replace XXX)

Workflow Configuration:
Import the JSON workflow into n8n
Update all credential references to match your accounts
Verify webhook URLs are properly configured for callback handling
Test the workflow and activate when ready

Optional Customizations:
Adjust the system prompt in the "Grok Imagine Agent" node for different behavior
Modify image aspect ratios or other parameters in the HTTP Request nodes
Add additional tools for more functionality

👉 Subscribe to my new YouTube channel. Here I’ll share videos and Shorts with practical tutorials and FREE templates for n8n.

Need help customizing?
Contact me for consulting and support or add me on Linkedin.

Nodes Used (9)

AI Agent
@n8n/n8n-nodes-langchain.agent
Call n8n Workflow Tool
@n8n/n8n-nodes-langchain.toolWorkflow
Code
n8n-nodes-base.code
FTP
n8n-nodes-base.ftp
HTTP Request
n8n-nodes-base.httpRequest
OpenAI
@n8n/n8n-nodes-langchain.openAi
OpenRouter Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenRouter
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow
Telegram
n8n-nodes-base.telegram