n8nflow.net logo

Generate AI Photos with Gemini & Auto-Post to Facebook, Instagram & X with Approval

by Feras DabourUpdated: Last update 2 days agoSource: n8n.io
Loading workflow viewer...

Getting Started

Social Media Foto Creation Bot with Approval Loop

Create & Share AI Photos with Telegram, Gemini & Post to Facebook, Instagram & X

Description
This n8n workflow turns your Telegram messenger into a complete AI Photo Content Pipeline. You send your photo idea as a text or voice message to a Telegram bot, collaborate with an AI to refine the prompt and social media caption, let Gemini generate the image, and then automatically publish it after your approval to Facebook, Instagram, and X (Twitter) – including status tracking and Telegram confirmations.


What You Need to Get Started

This workflow connects several external services. You will need the following credentials:

  • Telegram Bot API Key
    • Create a bot via BotFather and copy the bot token.
    • This is used by the Listen for incoming events and other Telegram nodes.
  • OpenAI API Key
    • Required for Speech to Text (OpenAI Whisper) to transcribe voice notes.
    • Used by the AI Agent model (OpenAI Chat Model) for prompt creation.
  • Google Gemini API Key
    • Used by the Generate an image node (model: models/gemini-2.5-flash-image) to create the AI image.
  • Google Drive & Sheets Access
    • The generated image is temporarily stored in a Google Drive folder (Upload image1) and later retrieved by Blotato.
    • Prompts and post texts are logged to Google Sheets (Save Prompt & Post-Text) for tracking.
  • Blotato API Key
    • The layer for social media publishing.
    • Uploads the image as a media asset (Upload media1) and creates posts for Facebook, Instagram, and X.

How the Workflow Operates – Step by Step

1. Input & Initial Processing (Telegram + Voice Handling)

This phase receives your messages and prepares the input for the AI.

Node NameRole in Workflow
Listen for incoming eventsTelegram Trigger node that starts the workflow on any incoming message.
Voice or TextSet node that structures the incoming message into a unified text field.
A Voice?IF node that checks if the message is a voice note.
Get Voice FileIf voice is detected, this downloads the audio file from Telegram.
Speech to TextUses OpenAI Whisper to convert the voice note into a text transcript.

The output of this stage is always a clean text string containing your image idea.

2. AI Core & Refinement Loop (Prompt + Caption via AI)

Here, the AI drafts the image prompt (for Gemini) and the social media caption (for all platforms) and enters an approval loop with you.

Node NameRole in Workflow
AI AgentCentral logic agent. Creates a videoPrompt (used for image generation) and socialMediaText based on your idea, and asks for feedback.
OpenAI Chat ModelThe LLM backing the agent (e.g., GPT-4.1-mini).
Window Buffer MemoryStores recent turns, allowing the agent to maintain context during revisions.
Send questions or proposal to userSends the AI's suggestion for review back to you.
Approved from user?IF node that checks if the output is the approved JSON (meaning you replied with "ok" or "approved").
Parse AI OutputCode node that extracts the videoPrompt and socialMediaText fields from the agent’s final JSON output.

3. Content Generation & Final Approval

Once the prompt and caption are set, the image is created and sent to you for final approval before publishing.

Node NameRole in Workflow
Inform user about processingTelegram node to confirm: "Okay. Your image is being prepared now..."
Save Prompt & Post-TextGoogle Sheets node that logs the videoPrompt and socialMediaText.
Generate an imageGemini node that creates the image based on the videoPrompt.
Send a photo messageSends the generated image to Telegram for review.
Send message and wait for responseTelegram node that waits for your response to the image (e.g., "Good?" / "Approve").
Upload image1Temporarily saves the generated image to Google Drive.
Download image from DriveDownloads the image back from Drive.
If1IF node that checks if the image was approved in the previous step (approved == true).

4. Upload & Publishing (Blotato)

After final approval, the image is uploaded to Blotato, and post submissions for the social media platforms are created.

Node NameRole in Workflow
Upload media1Blotato Media node. Uploads the approved image as a media asset and returns a public url.
Create instagram PostCreates an Instagram post using the media URL and socialMediaText.
Create x postCreates an X (Twitter) post using the media URL and socialMediaText.
Create FB postCreates a Facebook post using the media URL and socialMediaText.

5. Status Monitoring & Retry Loops (X, Facebook, Instagram)

An independent loop runs for each platform, polling Blotato until the post is either published or failed.

Node NameRole in Workflow
Wait, Wait1, Wait2Initial pauses after post creation.
Check Post Status, Get post1, Check Post Status1Blotato Get operations to fetch the current status of the post.
Published to X?, Published to Facebook?, Published to Instagram?IF nodes checking for the "published" status.
Confirm publishing to X, Confirm publishing to Facebook, Confirm publishing to InstagramTelegram nodes that notify you of successful publication (often including the post link).
In Progress?, In Progress?1, In Progress?2IF nodes that check for "in-progress" status and loop back to the Wait nodes (Give Blotat other 5s).
Send X Error Message, Send Facebook Error Message, Send Instagram Error MessageTelegram nodes that notify you if a failure occurs.

🛠️ Personalizing Your Content Bot

The workflow is highly adaptable to your personal brand and platform preferences:

  1. Tweak the AI Prompt & Behavior:
    • Where: In the AI Agent node, within the System Message.
    • Options: Change the tone (casual, professional, humorous) and the level of detail required for the prompt generation or the social media captions.
  2. Change Gemini Model or Image Options:
    • Where: In the Generate an image node.
    • Options: Swap the model or adjust image options like Aspect Ratio or Style based on Gemini's API capabilities.
  3. Modify Which Platforms You Post To:
    • Where: In the Blotato nodes: Create instagram Post , Create x post , Create FB post.
    • Options: Disable or delete branches for unused platforms, or add new platforms supported by Blotato.