AutomationFlowsAI & RAG › Generate Images with Pollinations & Blog Articles with Gemini 2.5 From Telegram

Generate Images with Pollinations & Blog Articles with Gemini 2.5 From Telegram

ByFahmi Oktafian @fahmi3322 on n8n.io

Generate AI images using Pollinations API, or Generate blog articles using Gemini AI

Event trigger★★★★★ complexityAI-powered34 nodesGoogle Gemini ChatTelegram TriggerTelegramHTTP RequestGoogle SheetsGoogle DriveChain Llm
AI & RAG Trigger: Event Nodes: 34 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #5844 — we link there as the canonical source.

This workflow follows the Chainllm → Google Drive 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 →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ad8656b2-a542-4942-a978-23bfe85721db",
      "name": "Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        560,
        260
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite-preview-06-17"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae3d4575-e1c9-4fc8-b4ef-d2394e24acb1",
      "name": "Trigger Telegram Message",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1280,
        -220
      ],
      "parameters": {
        "updates": [
          "callback_query",
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "116ee884-b2ea-42af-addd-5e335197c990",
      "name": "Classify Telegram Input",
      "type": "n8n-nodes-base.code",
      "position": [
        -1060,
        -220
      ],
      "parameters": {
        "jsCode": "let inputType = '';\n\nif ($json.hasOwnProperty(\"callback_query\")) {\n  const cbData = $json.callback_query.data || \"\";\n  \n  if (cbData.startsWith(\"style_\")) {\n    inputType = 'style';\n  } else {\n    inputType = 'callback_query';\n  }\n\n} else if (\n  $json.hasOwnProperty(\"message\") &&\n  $json.message.text === \"/start\"\n) {\n  inputType = 'message';\n\n} else if (\n  $json.hasOwnProperty(\"message\") &&\n  $json.message.text &&\n  $json.message.text.toLowerCase().startsWith(\"/help\")\n) {\n  inputType = \"help\";\n\n} else if (\n  $json.hasOwnProperty(\"message\") &&\n  $json.message.text\n) {\n  inputType = 'text';\n}\n\nreturn [\n  {\n    json: {\n      ...$json,\n      inputType\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7087e9ef-b1e6-486d-88f1-1a49397579c4",
      "name": "Switch Input Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -840,
        -240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "58bd7d4b-4553-4e9c-85ee-a92b50e1e93b",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "message"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "e5b29bef-e663-45e1-9e6e-21dde7e2627e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "=callback_query"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "75121808-30dd-4205-adef-e4c4d062ad37",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "text"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6dd8132d-6c99-4b01-b55a-be53cab37bb2",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "style"
                  }
                ]
              }
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "d5976879-6a5b-492c-82bd-e4189b4da648",
      "name": "Send Main Menu to User",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -620,
        -580
      ],
      "parameters": {
        "text": "Please choose a menu:",
        "chatId": "={{$json[\"message\"][\"chat\"][\"id\"]}}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Generate Image",
                    "additionalFields": {
                      "callback_data": "image"
                    }
                  },
                  {
                    "text": "Blog Article",
                    "additionalFields": {
                      "callback_data": "blog"
                    }
                  },
                  {
                    "text": "\u2753 Help",
                    "additionalFields": {
                      "callback_data": "help"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "01112b5e-05f5-4877-bf2d-16ed895b0801",
      "name": "Switch Callback Selection",
      "type": "n8n-nodes-base.switch",
      "position": [
        -640,
        -400
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "56c41166-8753-4a92-ae59-68949a001b74",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "image"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bd80f13b-f7c6-4578-b23a-5490a04b41b5",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "blog"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0274338b-4f92-4405-ba57-a80049db0b53",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "help"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "672826f4-1a49-41fe-ae3e-36365b5611c6",
      "name": "Prompt User for Image Description",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -360,
        -760
      ],
      "parameters": {
        "text": "Please send an image prompt, start with image",
        "chatId": "={{ $json.callback_query.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "09bc2384-c4c3-4a29-9910-e68622a0621d",
      "name": "Prompt User for Blog Title",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -360,
        -580
      ],
      "parameters": {
        "text": "Please submit article title, start with blog",
        "chatId": "={{ $json.callback_query.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9e8d3f41-0d4e-4a06-aab9-289fa374a3a7",
      "name": "Validate Command Format",
      "type": "n8n-nodes-base.if",
      "position": [
        -640,
        -220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f8a7aca4-5637-44aa-b3ce-dab8fcb25aec",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.text.startsWith('image') || $json.message.text.startsWith('blog') }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "892747b0-9fcf-4cca-b781-29d22f782a81",
      "name": "Detect Text-Based Input Type",
      "type": "n8n-nodes-base.set",
      "position": [
        -360,
        -240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a82b158b-21dc-4018-8887-1a936e50d525",
              "name": "=typeText",
              "type": "string",
              "value": "={{ $json.inputType === 'text' && $json.message.text && $json.message.text.toLowerCase().startsWith('blog') ? 'blog' : 'image' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0bf22449-827c-4b9a-991f-cf4d7b18b2c0",
      "name": "Switch Text Command Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -120,
        -240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8375ffa7-4f87-4dd6-ae62-6a908eb61b4f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.typeText }}",
                    "rightValue": "image"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bd572c93-d722-4953-a6d3-a3eb1c5f4e5f",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.typeText }}",
                    "rightValue": "=blog"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "7f184919-2d9e-4ec7-aa3b-f20720c42779",
      "name": "Build Image Generation URL",
      "type": "n8n-nodes-base.code",
      "position": [
        340,
        -340
      ],
      "parameters": {
        "jsCode": "const width = 1024;\nconst height = 1024;\nconst randomSeed = Math.floor(Math.random() * 100000);\n\nconst finalPrompt = $('Switch Input Type').first().json.message.text;\nconst imageUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(finalPrompt)}.jpg?width=${width}&height=${height}&seed=${randomSeed}&model=flux&nologo=true`;\n\nreturn [\n  {\n    json: {\n      text: finalPrompt,\n      imageUrl\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0699c5a1-a030-4a4f-be9e-8ff615dc4037",
      "name": "Download AI Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        560,
        -340
      ],
      "parameters": {
        "url": "={{ $json.imageUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "58b67910-d5ed-4993-b71d-a5ca4c31a1f9",
      "name": "Send Image Result to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        780,
        -340
      ],
      "parameters": {
        "chatId": "={{ $('Trigger Telegram Message').item.json.message.chat.id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5ad1b4cd-102d-4786-a11e-329cf9150a81",
      "name": "Log Image Prompt to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        960,
        -340
      ],
      "parameters": {
        "columns": {
          "value": {
            "date": "={{ new Date().toLocaleString() }}",
            "type": "image",
            "output": "={{ $('Download AI Image').item.json.imageUrl }}",
            "prompt": "={{ $('Download AI Image').item.json.text }}",
            "user id": "={{ $('Validate Command Format').item.json.message.chat.id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "c89ca7b4-3338-4497-90f0-d003562b3487",
      "name": "Upload Image to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        780,
        -520
      ],
      "parameters": {
        "name": "={{ $json.text }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1afFdG_eCYtca7fNAz1t7deKxIOcqZ0tv",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1afFdG_eCYtca7fNAz1t7deKxIOcqZ0tv",
          "cachedResultName": "telegram img generator assets"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "ef820546-a244-4b84-bead-914ddc4faeb0",
      "name": "Notify Invalid Input Format",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -360,
        -80
      ],
      "parameters": {
        "text": "\u274c Invalid format. Please use image your prompt or blog your title.",
        "chatId": "={{ $('Switch Input Type').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "de96a570-97cb-491b-bd2d-0c7d0798058c",
      "name": "Show Typing for Article Response",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        -120
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot[your-token]/sendChatAction",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $('Switch Input Type').item.json.message.chat.id }}"
            },
            {
              "name": "action",
              "value": "typing"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7573c3f9-4c6c-45d5-b7d6-2ace53258d29",
      "name": "Show Typing for Image Generation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        -340
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot[your-token]/sendChatAction",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $('Switch Input Type').item.json.message.chat.id }}"
            },
            {
              "name": "action",
              "value": "upload_photo"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "98ee826a-4cb5-415d-b974-23edd06b9a31",
      "name": "Send Help Instructions",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -360,
        -400
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot{YOUR-TOKEN}/sendMessage",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $json.callback_query.message.chat.id }}"
            },
            {
              "name": "parse_mode",
              "value": "Markdown"
            },
            {
              "name": "text",
              "value": "=Welcome! Here's how to use this bot:\n\n\ud83d\uddbc\ufe0f /image\nType the command:  \n`image of mountain scenery at sunrise`\n\n\ud83d\udcdd /blog \nType the command:  \n`blog What is MongoDB`\n\n\ud83e\uddfe Format:\n- Start with the keyword `image` or `blog`\n- After that, write a description or title\n- Without quotation marks\n\n\ud83d\udccc Correct Example:\n- `image of a futuristic house on a cloud`\n- `blog How to Learn React Native for Beginners`\n\nIf you are still confused, type `/start` to open the main menu.\n\nThank you! \ud83d\ude4c\n\nTranslated with DeepL.com (free version)"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "06407eb2-aafd-40aa-bb22-8970d2f08100",
      "name": "Send Article Style Options",
      "type": "n8n-nodes-base.telegram",
      "position": [
        780,
        -120
      ],
      "parameters": {
        "text": "Choose your preferred article style:",
        "chatId": "={{ $('Validate Command Format').item.json.message.chat.id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Formal",
                    "additionalFields": {
                      "callback_data": "style_formal"
                    }
                  },
                  {
                    "text": "Relax",
                    "additionalFields": {
                      "callback_data": "relax_style"
                    }
                  },
                  {
                    "text": "News",
                    "additionalFields": {
                      "callback_data": "news_style"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c4d2f57-d083-4a91-991f-6f58d1fef66d",
      "name": "Store Blog Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        340,
        -120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "30d22676-0174-4723-947e-5d8e604cd320",
              "name": "blogTitle",
              "type": "string",
              "value": "={{ $('Validate Command Format').item.json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c9503a8c-7a61-41db-bc3b-a1ea3c368a87",
      "name": "Log Blog Prompt to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        560,
        -120
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $('Validate Command Format').item.json.message.date }}",
            "prompt": "={{ $json.blogTitle }}",
            "user id": "={{ $('Validate Command Format').item.json.message.chat.id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "452c93e8-4ee9-4b81-a2cc-5e4f65e43864",
      "name": "Store Selected Article Style",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -120,
        80
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "=",
            "style": "={{ $json.callback_query.data.replace('style_', '') }}",
            "user id": "={{ $json.callback_query.message.chat.id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "user id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "gid=0"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "da632e75-b26c-44ea-8385-40710ae4259c",
      "name": "Fetch Last User Prompt",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        100,
        80
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json['user id'] }}",
              "lookupColumn": "user id"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "a5de2e3d-cd42-4725-bb41-08f9eed810e1",
      "name": "Extract Last Blog Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        340,
        80
      ],
      "parameters": {
        "jsCode": "const userId = $('Switch Input Type').first().json.callback_query.message.chat.id || $('Switch Input Type').first().json.callback_query.message.chat.id\n\nconst rows = items.map(item => item.json);\n\n// Filter data according to User ID\nconst filtered = rows.filter(r => r['user id'] == userId);\n\n// Take the last line of the user\nconst lastRow = filtered[filtered.length - 1];\n\nreturn [{ json: lastRow }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e605824e-3934-4bb1-8303-5ad3a144dd57",
      "name": "Generate Article with Gemini",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        580,
        80
      ],
      "parameters": {
        "text": "={{ $json.prompt }}",
        "messages": {
          "messageValues": [
            {
              "message": "=Write an English blog post based on the title: {{ $json.Prompt }}.\\n\\nLength about 3 paragraphs. Use the article style {{ $json.Style }}\n\ndo not add any introduction. directly provide the output.\n\nFollow the json format below :\n\n\n  {\n    \"title\": \"title\",\n    \"content\": \"content\"\n  }\n"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "dc89f75a-1e6d-4cd1-9cdb-d9779663496f",
      "name": "Parse Gemini Response",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        80
      ],
      "parameters": {
        "jsCode": "const raw = $json.text;\nconst clean = raw.replace(/```json|```/g, '').trim(); // optional: just in case the model still adds\nconst parsed = JSON.parse(clean);\nreturn [{ json: parsed }];"
      },
      "typeVersion": 2
    },
    {
      "id": "3107ddba-743b-4792-9731-bbd26873abcf",
      "name": "Send Article to Telegram",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1180,
        80
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot-YOURTOKEN/sendMessage",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $('Extract Last Blog Prompt').item.json['user id'] }}"
            },
            {
              "name": "text",
              "value": "={{ $json.title }}\n\n{{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5c5933cd-479e-4255-8ed4-115cfbbc1f01",
      "name": "Log Final Article to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1420,
        80
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "=",
            "date": "={{ new Date().toLocaleString() }}",
            "type": "blog",
            "output": "={{ $('Parse Gemini Response').item.json.content }}",
            "prompt": "={{ $('Parse Gemini Response').item.json.title }}",
            "user id": "={{ $json.result.chat.id }}",
            "row_number": "={{ $('Extract Last Blog Prompt').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "50a9f952-da98-4940-b53a-6c39fb97965b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3420,
        -1660
      ],
      "parameters": {
        "width": 640,
        "height": 940,
        "content": "# Generate Images with Pollinations AI & Blog Articles with Gemini 2.5 from Telegram\n\n\nThis workflow is a multi-functional Telegram bot that allows users to generate:\n\n - \ud83c\udfa8 AI images using Pollinations API\n - \ud83d\udcdd AI-written blog articles using [Gemini AI via LangChain]\n\n\nIt uses Google Sheets to log all user activities and Google Drive to store image assets.\n\n\n## \ud83d\udcf2 Example Commands:\nimage a modern smart city at sunset  \nblog The Benefits of Remote Work\n\n\n## \u2705 Features:\n  - Telegram Bot with menu buttons (/start)\n  - Detects message type: /start, /help, button callbacks, or free text\n  - Validates format (image ... or blog ...)\n  - Auto-routes command to:\n  - AI Image Generator\n  - Blog Article Generator\n  - Lets user choose article style: Formal, Casual, News\n  - Sends real-time feedback: typing, uploading, error\n  - Logs each entry to Google Sheets with timestamp\n  - Uploads images to Google Drive folder\n\n\n## \ud83e\uddfe Requirements:\n  - Telegram Bot Token\n  - Google Sheets OAuth credential\n  - Google Drive OAuth credential\n  - Google Gemini API (via LangChain)"
      },
      "typeVersion": 1
    },
    {
      "id": "c1a9d6fd-2c5b-4450-a2da-4d1e57602703",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2720,
        -1660
      ],
      "parameters": {
        "color": 3,
        "width": 640,
        "height": 680,
        "content": "## \u2699\ufe0f Setup Instructions:\n1. \ud83d\udd10 Add Credentials to your n8n:\n\n   - Telegram API\n   - Google Sheets OAuth\n   - Google Drive OAuth\n   - Google Gemini (PaLM) via LangChain\n\n2. \ud83e\udde9 Update Variables:\n\n   - Replace Google Sheet ID and Drive Folder ID\n   - Make sure chat_id expressions are dynamic (avoid hardcoding)\n\n3. \ud83e\uddea Test Commands:\n\n   - /start \u2192 opens main menu\n   - image your prompt \u2192 generates image\n   - blog your title \u2192 asks for style \u2192 generates article\n\n\n\n## \ud83d\udd27 Customization Tips:\n1. \u270d\ufe0f Modify Gemini prompt format in Generate Article with Gemini node\n2. \u2795 Add new style types like SEO, Story, Product Review\n3. \ud83d\uddbc Add more image models (e.g., Stability AI, DALL\u00b7E)\n4. \ud83d\udcca Add category/tags to Sheets for better reporting\n5. \ud83d\udcbe Save responses with filenames using timestamps"
      },
      "typeVersion": 1
    },
    {
      "id": "0f06dde2-108d-48b4-b2a9-ecd624c48c42",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2020,
        -1660
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 480,
        "content": "## \ud83d\udd10 Security Best Practices:\n1. Do NOT hardcode API keys into HTTP nodes\n2. Store all credentials via n8n credential manager\n3. Avoid exposing actual Sheet/Drive URLs in public templates\n\n\n## \ud83c\udfc1 Summary:\nA powerful Telegram bot for content creators that lets users generate image assets and full-length articles \u2014 without ever leaving the chat. Ideal for bloggers, designers, educators, marketers, and developers.\n\n\n## \ud83d\udd17 Want to Learn More?\n\ud83d\udcda https://n8n.partnerlinks.io/l3i5p47vr7s2\n\ud83d\udcda https://github.com/pollinations/pollinations\n\ud83d\udcda https://aistudio.google.com/apikey"
      },
      "typeVersion": 1
    },
    {
      "id": "f1271c8b-f7ba-4c62-93cc-02bb5504d767",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3420,
        -560
      ],
      "parameters": {
        "width": 920,
        "height": 1300,
        "content": "## \ud83d\udd01 Google Sheets Integration (\ud83d\udcc4 Logging System)\nThis workflow uses Google Sheets as a central log for all user activities and generated content.\n\nEach time a user sends a valid prompt (image or blog), a row is appended to the spreadsheet with relevant details.\n\n\n\n## \ud83d\udcca Sheet Structure\nThe spreadsheet is expected to have one sheet (e.g. Sheet1) with the following columns:\n\n| Column Name | Type     | Description                                                  |\n| ----------- | -------- | ------------------------------------------------------------ |\n| `Tanggal`   | `string` | Date and time of the request (`new Date().toLocaleString()`) |\n| `Prompt`    | `string` | The user\u2019s original prompt (image description or blog title) |\n| `User ID`   | `string` | Telegram user ID (from message/chat context)                 |\n| `Jenis`     | `string` | Type of generation: `\"image\"` or `\"blog\"`                    |\n| `Hasil`     | `string` | For images: the image URL; for blogs: full content           |\n| `Style`     | `string` | Writing style (only applicable for blog prompts)             |\n\n\n\n## \u2705 What\u2019s Logged?\nFor image prompts, it stores the image description, user ID, and image URL.\n\nFor blog prompts, it stores the blog title, selected writing style, and final article content.\n\n\n## \u2699\ufe0f Customizing Google Sheets for Other Use Cases\nYou can adapt the column names and fields for your own use. Here are suggestions:\n\n\ud83d\udccc Add a \u201cCategory\u201d column if you want to tag prompts (e.g., \u201cMarketing\u201d, \u201cTravel\u201d, \u201cNews\u201d)\n\n\ud83d\udccc Track response time by adding a Latency column using Date.now() logic\n\n\ud83d\udccc Include sentiment or keyword analysis with custom AI nodes\n\n\ud83d\udccc Use row_number to update specific entries if needed (already used in blog article flow)\n\n\nTo apply custom columns:\n\n- Open Log Image Prompt to Google Sheets, Log Blog Prompt to Google Sheets, or Log Final Article to Google Sheets node\n\n- Add new fields in the \u201cColumns\u201d > \u201cValue\u201d section\n\n- Map expressions or variables from the current data flow\n\n- Make sure your spreadsheet has matching headers to avoid errors.\n\n\n## \ud83d\udcc1 Google Drive Upload (for image)\nIn addition to logging to Sheets, AI-generated images are uploaded to a designated Google Drive folder for archiving.\n\nYou can change the folder ID in the Upload Image to Google Drive node and optionally rename the file to include:\n\nUser ID\nPrompt\nTimestamp"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Download AI Image": {
      "main": [
        [
          {
            "node": "Send Image Result to Telegram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload Image to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Article with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Store Blog Prompt": {
      "main": [
        [
          {
            "node": "Log Blog Prompt to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Input Type": {
      "main": [
        [
          {
            "node": "Send Main Menu to User",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch Callback Selection",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate Command Format",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Store Selected Article Style",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Gemini Response": {
      "main": [
        [
          {
            "node": "Send Article to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Last User Prompt": {
      "main": [
        [
          {
            "node": "Extract Last Blog Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Telegram Input": {
      "main": [
        [
          {
            "node": "Switch Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Command Format": {
      "main": [
        [
          {
            "node": "Detect Text-Based Input Type",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Invalid Input Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Last Blog Prompt": {
      "main": [
        [
          {
            "node": "Generate Article with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Article to Telegram": {
      "main": [
        [
          {
            "node": "Log Final Article to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Text Command Type": {
      "main": [
        [
          {
            "node": "Show Typing for Image Generation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Show Typing for Article Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Telegram Message": {
      "main": [
        [
          {
            "node": "Classify Telegram Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Callback Selection": {
      "main": [
        [
          {
            "node": "Prompt User for Image Description",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prompt User for Blog Title",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Help Instructions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Image Generation URL": {
      "main": [
        [
          {
            "node": "Download AI Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt User for Blog Title": {
      "main": [
        []
      ]
    },
    "Detect Text-Based Input Type": {
      "main": [
        [
          {
            "node": "Switch Text Command Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Article with Gemini": {
      "main": [
        [
          {
            "node": "Parse Gemini Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Selected Article Style": {
      "main": [
        [
          {
            "node": "Fetch Last User Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Image Result to Telegram": {
      "main": [
        [
          {
            "node": "Log Image Prompt to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Blog Prompt to Google Sheets": {
      "main": [
        [
          {
            "node": "Send Article Style Options",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Typing for Article Response": {
      "main": [
        [
          {
            "node": "Store Blog Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Typing for Image Generation": {
      "main": [
        [
          {
            "node": "Build Image Generation URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Image Prompt to Google Sheets": {
      "main": [
        []
      ]
    },
    "Log Final Article to Google Sheets": {
      "main": [
        []
      ]
    }
  }
}

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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Generate AI images using Pollinations API, or Generate blog articles using Gemini AI

Source: https://n8n.io/workflows/5844/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow creates a multi-talented AI assistant named Simran that interacts with users via Telegram. It can handle text and voice messages, understand the user's intent, and perform various tasks.

MongoDB, Chain Llm, Google Gemini Chat +11
AI & RAG

This automation is designed to help you generate AI-powered music tracks, cover art, and fully rendered music videos — all triggered from a simple Telegram chat and managed via Google Sheets.

OpenAI Chat, Memory Buffer Window, Output Parser Structured +11
AI & RAG

LinkedIn URL → Scrape → Match → Screen → Decide, all automated

Google Drive, Agent, Google Drive Tool +6
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Output Parser Structured, Telegram, N8N Nodes Tesseractjs +14
AI & RAG

This workflow turns any URL sent to a Telegram bot into ready-to-publish social posts: Trigger: Telegram message (checks if it contains a URL). Fetch & parse: Downloads the page and extracts readable

Telegram Trigger, HTTP Request, Google Sheets +5