Telegram AI Content Generator using Gemini and Pollinations - n8n Workflow

Use this advanced n8n workflow to build a powerful Telegram bot that generates AI images via Pollinations and structured blog articles using Google Gemini 2.5, logging all activity to Google Sheets.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Content creators needing quick AI asset and draft generation.

  • Developers seeking complex n8n templates for conversational AI and state management.

  • Marketers automating content production via a chat interface.

  • Users looking to integrate Google Gemini, Pollinations AI, Google Sheets, and Telegram in a single n8n solution.

Overview

This comprehensive n8n workflow provides a robust solution for deploying a generative AI chatbot directly within Telegram. It addresses the need for structured, multi-step automation by integrating two powerful AI services: Pollinations for image generation and Google Gemini 2.5 for writing coherent blog articles. A critical feature of this n8n workflow is its state management system, which uses Google Sheets to log every user action, prompt, and output, ensuring data persistence across conversational steps (especially for the multi-part blog generation flow). This makes it an ideal reference for advanced n8n templates focused on maximizing AI utility through messaging platforms. By using the Telegram n8n trigger, the entire experience is seamless for the end-user.

How it Works

This n8n workflow begins when the Telegram n8n trigger receives an update. The initial steps involve classifying the input type (Code n8n node) to route the request correctly.


  1. Input Routing: The flow checks for commands like /start (sends main menu), /help (sends instructions), or text inputs.

  2. Image Generation Path: If the text starts with image, the workflow sends a 'typing' action, then uses a Code n8n node to construct a request to Pollinations AI. An HTTP Request n8n node downloads the generated binary image. The Telegram n8n node sends the image back to the user. Concurrently, the image is uploaded to Google Drive and the prompt details are logged via a Google Sheets n8n node.

  3. Blog Prompt & Style Logging: If the text starts with blog, the initial title is captured and logged into Google Sheets. The workflow then prompts the user via a Telegram n8n node to select a preferred style (Formal, Relax, News) using inline keyboard buttons.

  4. Article Generation (Callback): When the user selects a style (a callback query is received), another Google Sheets n8n node updates the previously logged row with the selected style. The workflow then fetches the full prompt context from Google Sheets based on the user ID.

  5. Gemini Processing: The context is passed to the Generate Article with Gemini n8n node (a LangChain Chat Model n8n node), which uses Gemini 2.5 Flash Lite to create a blog post structured as JSON. After parsing the JSON (Code n8n node), the final article is sent back to Telegram, and the resulting content is logged back into Google Sheets, completing the automated n8n workflow cycle.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON and import it into your n8n instance.

  2. Credentials Setup: You must configure four critical credentials:

Telegram API: Needed for the Trigger Telegram Message n8n trigger and all subsequent Telegram nodes for communication.
Google Gemini API (via LangChain): Required for the Gemini Chat Model n8n node to power the article generation.
Google Sheets OAuth: Necessary for the Google Sheets n8n nodes used for logging and state management.
Google Drive OAuth: Used by the Google Drive n8n node to archive generated images.

  1. Webhook Configuration: Ensure your Telegram n8n trigger is correctly linked to your Telegram Bot (usually handled automatically by n8n when activated).

  2. Update HTTP Nodes: Replace [your-token] and {YOUR-TOKEN} placeholders in the HTTP Request n8n nodes (used for chat actions and sending final articles) with your actual Telegram Bot Token.

  3. Google Sheet & Drive IDs: Update the Sheet Document ID and Drive Folder ID in all Google Sheets and Google Drive n8n nodes to point to your specific logging spreadsheet and image archive folder.

Node Details

Trigger Telegram Message (n8n trigger): The initial entry point. Listens for both messages (text commands) and callback queries (button presses) from users.
Classify Telegram Input (Code n8n node): A custom JavaScript node that dynamically categorizes the incoming Telegram data (message, callback_query, text, style, help, etc.) to control flow.
Switch Input Type (Switch n8n node): Routes the workflow based on the category determined by the previous node.
Google Sheets (n8n node): This versatile node handles multiple operations: appending new prompts, updating existing rows with user style choices, retrieving the latest prompt, and finally updating rows with the generated content.
Build Image Generation URL (Code n8n node): Generates a dynamic Pollinations AI URL, including parameters for image dimensions and a random seed.
Download AI Image (HTTP Request n8n node): Fetches the AI image output as binary data, preparing it for Telegram submission and Google Drive archiving.
Upload Image to Google Drive (Google Drive n8n node): Stores the image output for historical tracking.
Generate Article with Gemini (Langchain n8n node): This core AI n8n node uses a structured prompt against Google Gemini 2.5 Flash Lite to produce a styled blog article in JSON format.
Parse Gemini Response (Code n8n node): Crucial for data integrity, this node strips markdown and converts the AI's JSON output into a usable data structure for the next steps in the n8n workflow.
Telegram / HTTP Request (Telegram n8n node): Used throughout the n8n workflow to send menus, ask follow-up questions (like article style selection), provide real-time feedback (typing actions), and deliver the final generated content.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by

Hi! I’m Fahmi Oktafian, a developer and automation enthusiast with expertise in n8n, Node.js, and API integrations. I specialize in building smart, scalable workflows — from auto-publishing content to WordPress, sending automated Telegram notifications, to processing AI-based summaries and paraphrase. I’m passionate about helping businesses save time, increase efficiency, and automate their digital processes with clean and user-friendly solutions.

Featured*