This workflow corresponds to n8n.io template #13367 — we link there as the canonical source.
This workflow follows the Agent → Execute Workflow Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "klLje7jNDPINkW4Y",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Image Grok Agent with Telegram",
"tags": [],
"nodes": [
{
"id": "20bc0b82-0680-4e01-a6d7-964726bbbb14",
"name": "Grok 4.1 Fast",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
-1920,
-432
],
"parameters": {
"model": "x-ai/grok-4.1-fast",
"options": {}
},
"credentials": {
"openRouterApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "8bde055b-3cfd-44f0-9d26-55ae340cc9f2",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2944,
-512
],
"parameters": {
"color": 7,
"width": 672,
"height": 288,
"content": "## STEP2 - Upload image to server\nSet up your FTP space (eg. with [BunnyCDN](https://bunny.net?ref=0pfu5rh4tp))\n"
},
"typeVersion": 1
},
{
"id": "81623604-9e24-4113-afcb-d13bd1e93950",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2032,
-816
],
"parameters": {
"color": 7,
"width": 544,
"height": 384,
"content": "## STEP 3 Orchestrator Agents\nAnalyzes user input and determines whether to:\n- Generate a new image from text description (text-to-image)\n- Transform an existing image using a prompt (image-to-image)\n"
},
"typeVersion": 1
},
{
"id": "55cca75a-ae19-4a67-ae44-744ab7a52f49",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
-3408,
-656
],
"parameters": {
"jsCode": "if ($input.first().json.message.from.id !== XXX) { // Replace with your Telegram user ID\n return { unauthorized: true };\n} else {\n // Return the original data when authorized\n return $input.all();\n}\n"
},
"typeVersion": 2
},
{
"id": "e34a35e5-c5a6-4d5f-93e2-d34e0b054291",
"name": "Get Message",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-3728,
-656
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "af686a4b-6de0-4cb8-bbea-04f12815a803",
"name": "Send a text message",
"type": "n8n-nodes-base.telegram",
"position": [
-1344,
-672
],
"parameters": {
"text": "={{ $json.output }}",
"chatId": "={{ $('Get Message').item.json.message.from.id }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "6129572e-5e0b-450e-9223-e379be3c64ad",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3504,
-752
],
"parameters": {
"color": 7,
"width": 528,
"height": 260,
"content": "## STEP 1 - Telegram and switch\nSet your Telegram ID here"
},
"typeVersion": 1
},
{
"id": "c1feb40e-89e5-4a58-b60a-a9beff7175b2",
"name": "Get Text",
"type": "n8n-nodes-base.set",
"position": [
-2464,
-896
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "029f4e7e-b367-4aa9-863e-e372694940fb",
"name": "chatInput",
"type": "string",
"value": "={{ $json.message.text }}"
},
{
"id": "398c1d7f-0c90-4af6-a414-d4d1968855b9",
"name": "sessionId",
"type": "number",
"value": "={{ $json.message.from.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f552f3e2-5be1-4806-ac44-128b75abd2ad",
"name": "Switch2",
"type": "n8n-nodes-base.switch",
"position": [
-3184,
-672
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text}}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Audio",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "7b2cb4dc-dd9d-43b2-b4db-f0de858f46cc",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice.file_id }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Immagine",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "98d80a35-3004-4bad-95b8-e87fc9270083",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.photo[0] }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"executeOnce": false,
"typeVersion": 3.2,
"alwaysOutputData": false
},
{
"id": "b8fc1ccf-2a00-4e71-a0ea-0c4b9a6b43d3",
"name": "Run text to image",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
-1536,
-416
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "klLje7jNDPINkW4Y",
"cachedResultUrl": "/workflow/klLje7jNDPINkW4Y",
"cachedResultName": "Video Grok Agent with Telegram"
},
"description": "Chiama questo tool solo quando devi modificare un video gi\u00e0 esistente. NON per crearlo",
"workflowInputs": {
"value": {
"query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
"duration": 0,
"tool_name": "Run text to image"
},
"schema": [
{
"id": "tool_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "tool_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "query",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "duration",
"type": "number",
"display": true,
"removed": false,
"required": false,
"displayName": "duration",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "video_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "video_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "image_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "image_url",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "b7da96ac-d65b-4694-bd26-60772c123fdd",
"name": "Wait1",
"type": "n8n-nodes-base.wait",
"position": [
-2960,
0
],
"parameters": {
"resume": "webhook",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 1.1
},
{
"id": "2f7c2d49-5c35-4573-947d-e25452e8a50d",
"name": "Run image to image",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
-1392,
-416
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "klLje7jNDPINkW4Y",
"cachedResultUrl": "/workflow/klLje7jNDPINkW4Y",
"cachedResultName": "Video Grok Agent with Telegram"
},
"description": "Chiama questo agente quando devi creare un'immagine partende daun'immagine esistente... dev inviare l'url e il prompt",
"workflowInputs": {
"value": {
"query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
"duration": 0,
"image_url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('image_url', `L'url dell'immagine`, 'string') }}",
"tool_name": "=Run image to image"
},
"schema": [
{
"id": "tool_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "tool_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "query",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "duration",
"type": "number",
"display": true,
"removed": false,
"required": false,
"displayName": "duration",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "video_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "video_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "image_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "image_url",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "f25c779d-9a31-489f-8b10-6f77804f3e81",
"name": "Wait2",
"type": "n8n-nodes-base.wait",
"position": [
-2944,
400
],
"parameters": {
"resume": "webhook",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 1.1
},
{
"id": "c00a8413-14d1-429c-8e72-6e92dc15a464",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
-3504,
208
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Run text to image",
"conditions": {
"options": {
"version": 3,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a8affc04-d75e-425b-a78b-0145b64b0624",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.tool_name }}",
"rightValue": "Run text to image"
}
]
},
"renameOutput": true
},
{
"outputKey": "Run image to image",
"conditions": {
"options": {
"version": 3,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "06f10d90-103a-41d3-9265-2d20f13fa146",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.tool_name }}",
"rightValue": "Run image to image"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.4
},
{
"id": "72382146-199e-48e3-a6b0-b5ea7973ae62",
"name": "Run Kei AI",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-3696,
208
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "tool_name"
},
{
"name": "query"
},
{
"name": "duration",
"type": "number"
},
{
"name": "video_url"
},
{
"name": "image_url"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "ccef57d4-8469-47b5-8e40-78323b491d89",
"name": "Run text to image1",
"type": "n8n-nodes-base.httpRequest",
"position": [
-3184,
0
],
"parameters": {
"url": "https://api.kie.ai/api/v1/jobs/createTask",
"method": "POST",
"options": {},
"jsonBody": "={\n \"model\": \"grok-imagine/text-to-image\",\n \"callBackUrl\": \"{{ $execution.resumeUrl }}\",\n \"input\": {\n \"prompt\": \"{{ $json.query }}\",\n \"aspect_ratio\": \"3:2\"\n }\n}",
"sendBody": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "4e978597-e964-4f12-9079-5742362224e9",
"name": "Run image to image1",
"type": "n8n-nodes-base.httpRequest",
"position": [
-3168,
400
],
"parameters": {
"url": "https://api.kie.ai/api/v1/jobs/createTask",
"method": "POST",
"options": {},
"jsonBody": "={\n \"model\": \"grok-imagine/image-to-image\",\n \"callBackUrl\": \"{{ $execution.resumeUrl }}\",\n \"input\": {\n \"prompt\": \"{{ $json.query }}\",\n \"image_urls\": [\n \"{{ $json.image_url }}\"\n ]\n }\n}",
"sendBody": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "c81563ee-8f79-4ae4-80f2-779b854ec6eb",
"name": "Result text to image",
"type": "n8n-nodes-base.httpRequest",
"position": [
-2736,
0
],
"parameters": {
"url": "=https://api.kie.ai/api/v1/jobs/recordInfo",
"options": {},
"sendQuery": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"queryParameters": {
"parameters": [
{
"name": "taskId",
"value": "={{ $('Run text to image1').item.json.data.taskId }}"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "30361085-5bda-4088-8f8c-f20c77e24729",
"name": "Result image to image",
"type": "n8n-nodes-base.httpRequest",
"position": [
-2720,
400
],
"parameters": {
"url": "=https://api.kie.ai/api/v1/jobs/recordInfo",
"options": {},
"sendQuery": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"queryParameters": {
"parameters": [
{
"name": "taskId",
"value": "={{ $('Run image to image1').item.json.data.taskId }}"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "c201993a-79b1-4f4e-9421-c75406b6d811",
"name": "Get voice message",
"type": "n8n-nodes-base.telegram",
"position": [
-2912,
-688
],
"parameters": {
"fileId": "={{ $('Get Message').item.json.message.voice.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "4eb9358d-4ca7-4f09-a7ed-92fd4166f974",
"name": "Transcribe recording",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-2688,
-688
],
"parameters": {
"options": {
"language": "it"
},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.7
},
{
"id": "303f065b-94e5-4752-9ce8-f964429cd949",
"name": "Get image file",
"type": "n8n-nodes-base.telegram",
"position": [
-2896,
-416
],
"parameters": {
"fileId": "={{ $json.message.photo[2].file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "bae9564b-11a8-471a-b453-1d51c6ab8d25",
"name": "Upload image",
"type": "n8n-nodes-base.ftp",
"position": [
-2672,
-416
],
"parameters": {
"path": "=/XXX/{{ $binary.data.fileName }}",
"options": {},
"operation": "upload"
},
"credentials": {
"ftp": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "95571314-da99-4483-85b8-873cf26789fa",
"name": "Set Image Url",
"type": "n8n-nodes-base.set",
"position": [
-2448,
-416
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "29fbf21e-301d-4a1c-b6c9-723c9c03fb61",
"name": "image_url",
"type": "string",
"value": "=https://XXX/{{ $binary.data.fileName }}"
},
{
"id": "272f6379-55fa-4d36-8da7-0ec1232606fd",
"name": "chatInput",
"type": "string",
"value": "={{ $('Get Message').item.json.message.caption || \"\"}}"
},
{
"id": "aff4f5c4-fe02-4bb8-b923-9c91334124ba",
"name": "sessionId",
"type": "string",
"value": "={{ $('Get Message').item.json.message.from.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "4923e186-f31c-4bbb-b811-ff567fc7870a",
"name": "Get input text from voice",
"type": "n8n-nodes-base.set",
"position": [
-2464,
-688
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "029f4e7e-b367-4aa9-863e-e372694940fb",
"name": "chatInput",
"type": "string",
"value": "={{ $json.text }}"
},
{
"id": "398c1d7f-0c90-4af6-a414-d4d1968855b9",
"name": "sessionId",
"type": "number",
"value": "={{ $('Get Message').item.json.message.from.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "b31fea73-8055-4cdf-aa89-1365fbd5beab",
"name": "Grok Imagine Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-1840,
-672
],
"parameters": {
"text": "={{ $json.chatInput ?? '' }}\n\nImage Url (if exist): {{ $json.image_url ?? '' }}",
"options": {
"systemMessage": "=You are an intelligent AI assistant integrated into a Telegram bot powered by n8n workflows. Your primary function is to help users create and manipulate images using AI generation tools.\n\n## Core Capabilities\n\nYou have access to two primary image generation tools:\n\n### 1. Text-to-Image Generation\n- **Tool name**: `run_text_to_image`\n- **Purpose**: Create images from text descriptions\n- **Required input**: A detailed prompt describing the desired image\n- **When to use**: When users request image creation without providing a source image\n\n### 2. Image-to-Image Generation\n- **Tool name**: `run_image_to_image`\n- **Purpose**: Transform or modify existing images based on text instructions\n- **Required inputs**: \n - A detailed prompt describing the desired modifications or style\n - The URL of the source image\n- **When to use**: When users want to modify, transform, or create variations of an existing image\n\n## Workflow Instructions\n\n### Step 1: Understand User Intent\n- Listen carefully to determine if the user wants to:\n - Generate a new image from scratch (text-to-image)\n - Modify or transform an existing image (image-to-image)\n- If the request is unclear, ask clarifying questions\n\n### Step 2: Gather Required Information\n\n**For text-to-image:**\n- If the user provides a basic description, enhance it into a detailed, high-quality prompt\n- Include style, composition, lighting, mood, and technical details when appropriate\n- Confirm the prompt with the user if significant enhancements were made\n\n**For image-to-image:**\n- Ensure you have the source image URL (from user upload or previous generation)\n- Create or refine the transformation prompt\n- Confirm both the source image and transformation intent\n\n### Step 3: Execute the Tool\n- Call the appropriate tool with properly formatted parameters\n- For `run_text_to_image`: Pass the refined prompt\n- For `run_image_to_image`: Pass both the prompt and image URL\n\n### Step 4: Process the Response\n- Carefully parse the JSON response from the tool\n- Extract all generated image URLs from the response structure\n- Handle potential response formats:\n - Single image objects\n - Arrays of images\n - Nested data structures\n- Check for errors or failed generations in the response\n\n### Step 5: Send Results to Telegram\n- Send each generated image to the user via Telegram\n- Include a brief description or confirmation message\n- If multiple images were generated, send them sequentially or as a group\n- Handle errors gracefully with clear user-friendly messages\n\n## Response Guidelines\n\n### Communication Style\n- Be friendly, concise, and helpful\n- Use clear language appropriate for creative workflows\n- Show enthusiasm for the creative process\n- Provide constructive guidance on improving prompts\n\n### Prompt Enhancement\nWhen enhancing user prompts, consider adding:\n- **Style references**: (e.g., \"photorealistic\", \"oil painting\", \"anime style\")\n- **Technical details**: (e.g., \"8K resolution\", \"dramatic lighting\", \"shallow depth of field\")\n- **Composition**: (e.g., \"centered composition\", \"rule of thirds\", \"close-up portrait\")\n- **Mood and atmosphere**: (e.g., \"moody\", \"vibrant\", \"ethereal\", \"cinematic\")\n- **Quality markers**: (e.g., \"highly detailed\", \"professional photography\", \"award-winning\")\n\n### Error Handling\n- If a tool call fails, explain the issue clearly\n- Offer to retry with adjusted parameters\n- Suggest alternatives if the original approach isn't working\n- Never expose raw error messages; translate them into user-friendly explanations\n\n### Best Practices\n- Always confirm you're processing the request before calling tools\n- Provide status updates for operations that might take time\n- Ask for feedback on generated images\n- Offer to make adjustments or create variations\n- Keep track of conversation context to reference previous generations\n\n## Example Interactions\n\n**User**: \"Create an image of a sunset\"\n**You**: \"I'll create a beautiful sunset image for you. Let me enhance that prompt for better results...\"\n*[Call run_text_to_image with enhanced prompt: \"A breathtaking sunset over the ocean, vibrant orange and pink clouds, golden hour lighting, peaceful atmosphere, high quality photograph, 4K resolution\"]*\n*[Parse response, extract image URL, send to Telegram]*\n**You**: \"Here's your stunning sunset image! Would you like me to create any variations or adjust anything?\"\n\n**User**: *[Uploads image]* \"Make this look like a Van Gogh painting\"\n**You**: \"Great! I'll transform your image using Van Gogh's distinctive style...\"\n*[Call run_image_to_image with prompt: \"Transform into Van Gogh style painting, post-impressionist, bold brushstrokes, swirling patterns, vibrant colors, oil painting texture\" and the uploaded image URL]*\n*[Parse response, send result]*\n**You**: \"Here's your image in Van Gogh's style! The characteristic swirling brushstrokes really bring it to life.\"\n\n## Technical Notes\n\n- Always validate that required parameters are present before calling tools\n- Handle JSON parsing errors gracefully\n- Support multiple image formats in responses\n- Maintain conversation context for follow-up requests\n- Log errors internally while showing friendly messages to users\n\nRemember: Your goal is to make AI image generation accessible, fun, and powerful for Telegram users while handling all technical complexity behind the scenes."
},
"promptType": "define"
},
"typeVersion": 3.1
},
{
"id": "3572cc8a-3d80-4dac-9b3e-dfed740c6d81",
"name": "Simple Memory1",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-1760,
-432
],
"parameters": {
"sessionKey": "={{$json.sessionId}}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "7f9b85ee-00ce-45e4-99ed-faf3d3cf2158",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3328,
-144
],
"parameters": {
"color": 7,
"width": 880,
"height": 784,
"content": "## STEP 4 - Kie AI API\nGet your [Kie API Key](https://kie.ai?ref=188b79f5cb949c9e875357ac098e1ff5) for FREE and set Bearer Token"
},
"typeVersion": 1
},
{
"id": "35655d03-5cd9-4140-868e-e3f84b600307",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3760,
-1424
],
"parameters": {
"width": 784,
"height": 640,
"content": "## Image Generator Bot for Telegram (Text and Voice) using Grok Imagine via Kie AI\nThis workflow creates an **AI-powered Telegram bot** that allows users to generate and modify images using **Grok Imagine models** via the [Kie AI API](https://kie.ai?ref=188b79f5cb949c9e875357ac098e1ff5)\n\n### How it works:\n\nThis workflow builds an AI-powered Telegram bot that generates or transforms images using Grok Imagine models via the Kie ai API. It processes multi-modal inputs (text, voice, images), authenticates users by Telegram ID, transcribes voice with Whisper, and uploads images to FTP (e.g., BunnyCDN) to obtain public URLs. A Grok-powered AI agent analyzes intent, enhances prompts, and automatically selects the correct tool (text-to-image or image-to-image), triggering specialized workflows that call the appropriate Kie ai endpoints.\n\nImage generation runs asynchronously using task IDs, Wait nodes, and polling to prevent timeouts. Once processing is complete, the generated image is returned to the user via Telegram. The architecture separates orchestration, tool execution, and delivery, enabling scalable, modular, and production-ready automation.\n\n### Setup steps:\n\nConfigure Telegram by creating a bot via BotFather, adding your Telegram user ID in the Code node, and setting Telegram credentials in n8n. Set up required API keys: OpenRouter (for Grok 4.1 Fast), Kie ai (for image generation models), and OpenAI (for Whisper transcription). Configure an FTP server (e.g., BunnyCDN) for hosting user-uploaded images and update credentials and public URL paths in the relevant nodes.\n\nImport the workflow JSON into n8n, update all credential references, and verify webhook URLs for asynchronous callbacks. Test end-to-end execution before activating. Optionally customize the AI agent\u2019s system prompt, adjust image parameters in HTTP Request nodes, or extend the tool-based architecture with additional capabilities like video generation or advanced editing.\n"
},
"typeVersion": 1
},
{
"id": "96bed25d-19d0-4944-843b-6084b27bb0d7",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-4528,
-1520
],
"parameters": {
"color": 7,
"width": 736,
"height": 736,
"content": "## MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new **YouTube channel**](https://youtube.com/@n3witalia). Here I\u2019ll share videos and Shorts with practical tutorials and **FREE templates for n8n**.\n\n[](https://youtube.com/@n3witalia)"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"availableInMCP": false,
"executionOrder": "v1"
},
"versionId": "302c6f21-3fa3-425d-b589-cf629267e683",
"connections": {
"Code": {
"main": [
[
{
"node": "Switch2",
"type": "main",
"index": 0
}
]
]
},
"Wait1": {
"main": [
[
{
"node": "Result text to image",
"type": "main",
"index": 0
}
]
]
},
"Wait2": {
"main": [
[
{
"node": "Result image to image",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Run text to image1",
"type": "main",
"index": 0
}
],
[
{
"node": "Run image to image1",
"type": "main",
"index": 0
}
]
]
},
"Switch2": {
"main": [
[
{
"node": "Get Text",
"type": "main",
"index": 0
}
],
[
{
"node": "Get voice message",
"type": "main",
"index": 0
}
],
[
{
"node": "Get image file",
"type": "main",
"index": 0
}
]
]
},
"Get Text": {
"main": [
[
{
"node": "Grok Imagine Agent",
"type": "main",
"index": 0
}
]
]
},
"Run Kei AI": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Get Message": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Upload image": {
"main": [
[
{
"node": "Set Image Url",
"type": "main",
"index": 0
}
]
]
},
"Grok 4.1 Fast": {
"ai_languageModel": [
[
{
"node": "Grok Imagine Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Set Image Url": {
"main": [
[
{
"node": "Grok Imagine Agent",
"type": "main",
"index": 0
}
]
]
},
"Get image file": {
"main": [
[
{
"node": "Upload image",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory1": {
"ai_memory": [
[
{
"node": "Grok Imagine Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Get voice message": {
"main": [
[
{
"node": "Transcribe recording",
"type": "main",
"index": 0
}
]
]
},
"Run text to image": {
"ai_tool": [
[
{
"node": "Grok Imagine Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Grok Imagine Agent": {
"main": [
[
{
"node": "Send a text message",
"type": "main",
"index": 0
}
]
]
},
"Run image to image": {
"ai_tool": [
[
{
"node": "Grok Imagine Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Run text to image1": {
"main": [
[
{
"node": "Wait1",
"type": "main",
"index": 0
}
]
]
},
"Run image to image1": {
"main": [
[
{
"node": "Wait2",
"type": "main",
"index": 0
}
]
]
},
"Transcribe recording": {
"main": [
[
{
"node": "Get input text from voice",
"type": "main",
"index": 0
}
]
]
},
"Get input text from voice": {
"main": [
[
{
"node": "Grok Imagine Agent",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
ftphttpBearerAuthopenAiApiopenRouterApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
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.
Source: https://n8n.io/workflows/13367/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
The AI-Powered Shopify SEO Content Automation is an enterprise-grade workflow that transforms product content creation for e-commerce stores. This sophisticated multi-agent system integrates GPT-4o, C
RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.
How it Works
Digital marketers, content creators, social media managers, and businesses who want to use AI marketing automation for YouTube Shorts without spending hours on production. This AI workflow helps anyon
Who is this for? Agencies, consultants, and service providers who conduct discovery calls and need to quickly turn conversations into professional proposals.