AI Automation System

Voice → Image Generator

Telegram bot that converts voice messages into AI-generated images using AssemblyAI, GPT-4 & DALL-E.
n8n Telegram Bot AssemblyAI OpenAI GPT-4 DALL-E

Context & Problem

Voice → Text → Prompt → Image

Creating visual content usually requires precise typing of prompts. Users often have visual ideas while speaking (voice notes), but the friction of transcribing and formatting prompts discourages them.

Challenge: Transcribing audio manually is slow. Automatic transcription needs to be high-quality. The text must then be intelligently transformed into a detailed image prompt, and finally rendered into an image — all seamlessly within a chat interface.

Goal: Build a Telegram bot that accepts voice/audio, transcribes it, generates a creative image prompt, creates the image, and returns it to the user instantly.

Implementation

Workflow Pipeline

An event-driven n8n workflow triggers on new Telegram messages. It validates the input (voice/audio), handles commands (/start, /reset), and processes audio via AssemblyAI. A polling loop ensures the transcript is ready before sending it to GPT-4 for prompt engineering, followed by DALL-E generation.

  • Telegram Trigger → Listens for updates (messages, voice, files)
  • Validation Router → Checks for /start, /reset, or voice/file presence
  • AssemblyAI → Uploads audio, requests transcription, polls for completion
  • GPT-4 Prompting → Converts transcribed text into a structured JSON image prompt
  • DALL-E 3 → Generates the image based on the engineered prompt
Telegram Voice to Image Workflow
Fig 1. High-level workflow architecture
System Prompt (GPT-4)
Ти — асистент, який генерує зображення СУВОРО за останнім запитом користувача.

КРИТИЧНО ВАЖЛИВО:
- Використовуй ТІЛЬКИ поточний текст транскрипції.
- Повністю ігноруй попередні теми, стилі, персонажів...
- Кожен новий запит обробляється як повністю новий незалежний сценарій.

ФОРМАТ ВИХОДУ (ОБОВʼЯЗКОВО):
Поверни ТІЛЬКИ валідний JSON.
{
  "caption": "Українською, 50-200 символів, з emoji",
  "image_prompt": "English, 60-150 words, detailed visual description",
  "tts_text": "Українською, 1-2 речення"
}

... (Full prompt includes constraints for style, mood, lighting, prohibited content handling)
JavaScript (Parsing GPT Response)
// Parse JSON returned as text by 'Message a model1'
const chat_id = $node["Edit Fields1"].json.chat_id;
const raw = $json?.output?.[0]?.content?.[0]?.text ?? $json?.text ?? "";

let parsed;
try {
  parsed = JSON.parse(raw);
} catch (e) {
  throw new Error("Model did not return valid JSON. Raw: " + raw.slice(0, 400));
}

return [{
  json: {
    chat_id,
    caption: parsed.caption ?? "",
    image_prompt: parsed.image_prompt ?? "",
    tts_text: parsed.tts_text ?? ""
  }
}];

Results & Impact

User Experience & Automation
Technical Flow
  • Instant Telegram response
  • Multilingual transcription
  • Context-aware prompting
  • High-quality DALL-E output
Features
  • /start command for instructions
  • /reset to clear context
  • Polling loop for async transcription
  • Error handling for file types
User Value
  • Create art from voice notes
  • No prompt engineering skills needed
  • Fun, interactive AI experience
  • Accessible via standard Telegram

Export Workflow

Download the full n8n workflow JSON (Telegram Voice to Image) and import it into your n8n instance.