{
  "id": "PEwdJywfvAhmN22b",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI LinkedIn Post Assistant with Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "55de8a36-6f38-46b8-8af0-f61de4eb6770",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -480,
        320
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": false,
      "typeVersion": 1.2
    },
    {
      "id": "f215cb2c-574a-4c41-ab31-9465ca32db87",
      "name": "LinkedIn Post Generator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        768,
        128
      ],
      "parameters": {
        "text": "={{ $json.topic }}",
        "options": {
          "systemMessage": "# **System Prompt: LinkedIn Content Strategist (General-Purpose AI Agent)**\n\nYou are a top-tier LinkedIn strategist and content creator who helps grow accounts through authentic, high-performing posts.\n\n## \ud83c\udfaf Goal\n\nBuild authority & personal brand with a KPI focused on follower growth and engagement.\n\n## \ud83e\udde0 Core Function\n\nYou are part of an AI agent that receives a **topic from the user**.\nYour task is to **create a compelling LinkedIn post based on that topic**, optimized for engagement, clarity, and shareability.\n\n## \ud83e\udde9 Niche & Positioning\n\nKeep the content **general and adaptable to any topic provided by the user**.\nDo not assume a fixed niche unless explicitly mentioned in the input topic.\n\n## \ud83d\udc65 Audience Persona\n\nProfessionals, creators, founders, freelancers, and decision-makers looking to learn, grow, and gain insights across various domains.\n\n## \ud83e\uddf1 Content Pillars\n\nAdapt dynamically based on the topic. Common formats include:\n\n* Personal insights or lessons\n* Story-driven experiences\n* Actionable tips or frameworks\n* Industry trends or observations\n* Thought-provoking opinions\n\n## \ud83d\udde3\ufe0f Voice & Tone\n\nStorytelling with emotion, educational, and structured.\n**Do:** Focus on relatability, clarity, and value.\n**Don't:** Use overly technical jargon unless required by the topic.\n\n## \ud83d\udcad Core Beliefs\n\n* Valuable content is simple, relatable, and actionable.\n* Consistency builds authority.\n* Storytelling increases engagement and retention.\n\n## \ud83d\udcc8 Proof & Credibility\n\nWhere relevant, include:\n\n* Examples\n* Personal experiences (real or illustrative)\n* Observations or insights\n\n## \ud83c\udfac Hook & Structure Preferences\n\nHook styles: Pain-point hook, Story hook, Curiosity hook\nPost structure: Hook \u2192 Problem/Insight \u2192 Solution/Takeaway \u2192 CTA\n\nEmoji/Hashtag policy:\n\n* Use natural emojis for readability\n* Use up to 5 relevant hashtags\n\n## \ud83e\uddf2 CTA & Offers\n\nUse soft, engaging CTAs such as:\n\n* Ask a question\n* Invite opinions\n* Encourage comments or shares\n\nFrequency: Include a CTA when it feels natural (not forced in every post).\n\n## \u2694\ufe0f Differentiation\n\nFocus on **clarity, relatability, and strong storytelling** rather than niche authority.\nMake posts feel human, not robotic.\n\n## \ud83c\udf0f Localization & Language\n\nContent should be written in clear, natural English.\n\n## \ud83d\udeab Taboo Topics\n\n* Avoid unnecessary complexity\n* Avoid overly niche assumptions unless provided in the topic\n\n---\n\n## \ud83d\udcdd Post Format to Follow\n\n### **Hook \u2192 Insight \u2192 Value \u2192 CTA (Flexible Structure)**\n\n\u2728 **Why it works:** Universal, adaptable to any topic, and highly engaging.\n\n**Structure:**\n\n\ud83e\ude9d **Hook:** Scroll-stopping first line (pain, curiosity, or bold statement)\n\ud83d\udca1 **Insight/Problem:** Expand on the idea or highlight the issue\n\u2705 **Value:** Provide actionable takeaways, lessons, or perspectives\n\ud83d\udd22 **Breakdown (optional):** 3\u20135 key points for clarity\n\ud83d\udce3 **CTA:** Invite engagement (question or prompt)\n\n---\n\n### **Example Template**\n\n[Hook]\n\n[Relatable insight or problem]\n\nHere\u2019s what I\u2019ve learned:\n\n1\ufe0f\u20e3 [Point]\n2\ufe0f\u20e3 [Point]\n3\ufe0f\u20e3 [Point]\n\n[Closing takeaway]\n\n[CTA]\n\n---\n\n## \u2699\ufe0f Final Instruction\n\nAlways generate a **complete, ready-to-post LinkedIn post** based on the given topic.\nDo not include explanations or meta commentary\u2014only the final post."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "1d306a0a-dc0e-45b1-84c3-4c0b519eb8b4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        752,
        272
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4",
          "cachedResultName": "gpt-4"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5ea693c5-0e1c-462f-80a7-fa296877d07f",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        864,
        288
      ],
      "parameters": {
        "sessionKey": "=={{ $json.chatId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "bcbc2172-97f3-4872-908b-87a7f5fecdc1",
      "name": "Save Draft",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        128
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst postContent = $json.output;\nconst existing = data[chatId] || {};\n\n// New topic = fresh draft, but preserve approved image if it exists\ndata[chatId] = {\n  postContent,\n  status: 'pending',\n  updatedAt: new Date().toISOString(),\n\n  // Preserve approved image from previous session\n  imageStatus: existing.imageApproved ? existing.imageStatus : 'none',\n  imageApproved: existing.imageApproved || false,\n  imageSource: existing.imageApproved ? existing.imageSource : '',\n  imagePrompt: existing.imageApproved ? existing.imagePrompt : '',\n  telegramFileId: existing.imageApproved ? existing.telegramFileId : '',\n  imageUrl: existing.imageApproved ? existing.imageUrl : '',\n  imageMimeType: existing.imageApproved ? existing.imageMimeType : '',\n  imageFileName: existing.imageApproved ? existing.imageFileName : '',\n};\n\nreturn [\n  {\n    json: {\n      chatId,\n      postContent,\n      status: 'pending',\n      imageStatus: data[chatId].imageStatus,\n      imageApproved: data[chatId].imageApproved,\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "b148df8b-49af-4ffa-9411-3a9663ea763c",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1344,
        128
      ],
      "parameters": {
        "text": "=\ud83d\udcdd *LinkedIn Post Draft*\n\n{{ $json.postContent }}\n\n---\nReply with:\n\u2022 'approve' to post immediately\n\u2022 '/image ai..(img description)' to include image\n\u2022 Your feedback to request revisions",
        "chatId": "={{ $json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8d4b3e09-4db1-449d-8522-c3d40ef18aa1",
      "name": "Get Saved Draft",
      "type": "n8n-nodes-base.code",
      "position": [
        528,
        -448
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst savedDraft = data[chatId] || {};\n\nreturn [\n  {\n    json: {\n      chatId,\n      postContent: savedDraft.postContent || '',\n      status: savedDraft.status || '',\n      imageApproved: savedDraft.imageApproved || false,\n      imageStatus: savedDraft.imageStatus || 'none',\n      imageUrl: savedDraft.imageUrl || '',\n      telegramFileId: savedDraft.telegramFileId || '',\n\n      imageMimeType: savedDraft.imageMimeType || '',\n      imageFileName: savedDraft.imageFileName || '',\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "9612ce71-263d-4451-a7fc-5ceb9726c0f7",
      "name": "Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1712,
        -448
      ],
      "parameters": {
        "text": "\u2705 *Posted to LinkedIn!*||Your post has been successfully published.",
        "chatId": "={{ $('Get Saved Draft').first().json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b0c18c67-7a70-4620-921e-0c54fee70c68",
      "name": "Revise LinkedIn Post",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        752,
        448
      ],
      "parameters": {
        "text": "=Current draft:\n{{ $json.currentDraft }}\n\nUser feedback:\n{{ $json.feedback }}\n\nRevise the draft accordingly.",
        "options": {
          "systemMessage": "*Post Refinement Instruction*\n\nWhen a previously generated LinkedIn post is provided:\n\nTreat it as a draft that needs improvement or modification, not a new post\n\nApply only the specific changes requested by the user\n\nPreserve the original tone, structure, and intent unless explicitly asked to change\n\nImprove clarity, engagement, and flow where possible\n\nDo not over-edit or completely rewrite unless instructed\n\nOutput only the final revised post (ready to publish). Do not explain changes."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "560f5c88-0012-44a2-a682-66da38828337",
      "name": "Save Revised Draft",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        448
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\nconst chatId = $('Prepare Feedback from AI Intent').first().json.chatId;\nconst postContent = $json.output;\n\nconst existing = data[chatId] || {};\n\ndata[chatId] = {\n  postContent,\n  status: 'pending',\n  updatedAt: new Date().toISOString(),\n\n  // preserve existing image state\n  imageStatus: existing.imageStatus || 'none',\n  imageApproved: existing.imageApproved || false,\n  imageSource: existing.imageSource || '',\n  imagePrompt: existing.imagePrompt || '',\n  telegramFileId: existing.telegramFileId || '',\n  imageUrl: existing.imageUrl || '',\n\n  // preserve stored exact image payload\n  imageMimeType: existing.imageMimeType || '',\n  imageFileName: existing.imageFileName || '',\n};\n\nreturn [\n  {\n    json: {\n      chatId,\n      postContent,\n      status: 'pending',\n      imageStatus: data[chatId].imageStatus,\n      imageApproved: data[chatId].imageApproved,\n      imageUrl: data[chatId].imageUrl,\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "a791fdfc-dc0a-4146-9d9d-ac87ed717b5e",
      "name": "Send Revised Draft",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1328,
        448
      ],
      "parameters": {
        "text": "=\ud83d\udd04 *Revised LinkedIn Post*\n\n{{ $json.postContent }}\n\nReply with:\n\u2022 'approve' to post immediately\n\u2022 '/image ai..(img description)' to include image\n\u2022 Your feedback to request revisions",
        "chatId": "={{ $json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2db70608-3250-4ade-91dc-f1c8f7d95580",
      "name": "Create Image Prompt",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        704,
        800
      ],
      "parameters": {
        "text": "=Create a detailed prompt for generating a professional LinkedIn post image based on this request:\n\n{{ $json.imagePrompt }}",
        "options": {
          "systemMessage": "You are an expert prompt writer for AI image generation.\n\nCreate a single high-quality image generation prompt for a professional LinkedIn post image.\n\nRules:\n- Make it visually clear and polished\n- Keep it professional and business-friendly\n- Prefer clean composition, modern style, strong focal point\n- Avoid text inside the image unless explicitly requested\n- Output only the final image prompt\n- Do not explain anything"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "c12c0047-737c-47d7-bd60-099523922b02",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        688,
        976
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4",
          "cachedResultName": "gpt-4"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "641fa4bd-8809-4949-98b1-398c9045d837",
      "name": "Generate AI Image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        992,
        784
      ],
      "parameters": {
        "prompt": "={{ $json.output }}",
        "options": {
          "size": "1024x1024",
          "returnImageUrls": true
        },
        "resource": "image"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "48b0a60c-084a-4697-85b5-dc0a6030ffdf",
      "name": "Save AI Image",
      "type": "n8n-nodes-base.code",
      "position": [
        1104,
        976
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst item = $input.first();\n\nconst imageUrl =\n  item.json.data?.[0]?.url ||\n  item.json.url ||\n  item.json.output?.[0]?.url ||\n  item.json.image_url ||\n  '';\n\nconst existing = data[chatId] || {};\n\ndata[chatId] = {\n  ...existing,\n  imageStatus: 'pending',\n  imageApproved: false,\n  imageSource: 'ai',\n  imageUrl,\n  updatedAt: new Date().toISOString(),\n};\n\nreturn [\n  {\n    json: {\n      chatId,\n      imageUrl,\n      imageStatus: 'pending',\n      imageApproved: false,\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "7b048a95-daf9-4881-ae1b-efc497e3c431",
      "name": "Approve Image",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        1216
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst existing = data[chatId] || {};\n\nconst hasImage = !!(existing.imageUrl || existing.telegramFileId);\n\nif (!hasImage) {\n  return [\n    {\n      json: {\n        chatId,\n        ok: false,\n        message: 'No pending image found. Generate one with /image ai ... or upload an image first.',\n      },\n    },\n  ];\n}\n\ndata[chatId] = {\n  ...existing,\n  imageStatus: 'approved',\n  imageApproved: true,\n  updatedAt: new Date().toISOString(),\n};\n\nreturn [\n  {\n    json: {\n      chatId,\n      ok: true,\n      imageStatus: 'approved',\n      imageApproved: true,\n      message: 'Image approved',\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "ab519c9e-77b6-4298-9892-803471d123f6",
      "name": "Confirm Image Approval",
      "type": "n8n-nodes-base.telegram",
      "position": [
        992,
        1168
      ],
      "parameters": {
        "text": "=\u2705 *Image approved*\n\nNow you can:\n\u2022 send `approve` to post with image\n\u2022 or continue editing the post",
        "chatId": "={{ $json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "279fb42a-0403-4e2d-aa32-a685ebc7119c",
      "name": "Check Image Status",
      "type": "n8n-nodes-base.switch",
      "position": [
        1040,
        -352
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "With Image",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b8403b5c-c636-4bcd-a32a-51b3d912f9ef",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.imageApproved }}",
                    "rightValue": "true"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bb64c5c1-1637-43de-8631-168f9b422733",
      "name": "Post Text Only",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        1264,
        -448
      ],
      "parameters": {
        "text": "={{ $json.postContent }}",
        "person": "0iutWNMF-o",
        "additionalFields": {}
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f83366d9-59e7-49a7-a24a-20d533f9c66a",
      "name": "Confirmation With Image",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2384,
        -256
      ],
      "parameters": {
        "text": "\u2705 *Posted to LinkedIn!*\n\nYour post has been successfully published with Image.",
        "chatId": "={{ $('Get Saved Draft').first().json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4e75364c-1ae8-481e-887a-39488ede77e0",
      "name": "Check Image Approval Result",
      "type": "n8n-nodes-base.switch",
      "position": [
        704,
        1216
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Success",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4d4e5217-dd44-43d3-a307-878f58950399",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.ok }}",
                    "rightValue": "true"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "714cb297-7a3c-4894-af17-acae1ee79df9",
      "name": "Image Approval Error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        992,
        1360
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d11b15b2-45f8-4fd9-b518-3ea31a9f69e9",
      "name": "Check Final Post Readiness",
      "type": "n8n-nodes-base.switch",
      "position": [
        752,
        -448
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Image Pending",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "773ba4ad-4af3-4728-ae09-d297d9207b27",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.imageStatus }}",
                    "rightValue": "pending"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8e5b41ec-858a-47d4-81ad-c9e464fb1a35",
      "name": "Image Not Approved Warning",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1056,
        -560
      ],
      "parameters": {
        "text": "=\u26a0\ufe0f You have a pending image that is not approved yet.\n\nSend `approve image` to use it in the post, or generate/upload a different image.",
        "chatId": "={{ $json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "43c4f44f-c065-4b12-a895-f633797da22b",
      "name": "Send a photo message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1216,
        768
      ],
      "parameters": {
        "file": "={{ $json.imageUrl }}",
        "chatId": "={{ $json.chatId }}",
        "operation": "sendPhoto",
        "additionalFields": {
          "caption": "=\ud83d\uddbc\ufe0f *Image Preview*\n\nReply with:\n\u2022 `approve image` to use this image\n\u2022 or send another `/image ai ...` to regenerate",
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "88aac14e-0160-46c5-ac1b-9e5717214d09",
      "name": "Save Telegram Image File ID",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        976
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\n\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst existing = data[chatId] || {};\n\nconst photos = $input.first().json.result?.photo || [];\nconst largestPhoto = photos[photos.length - 1] || null;\nconst telegramFileId = largestPhoto?.file_id || '';\n\ndata[chatId] = {\n  ...existing,\n  telegramFileId,\n  updatedAt: new Date().toISOString(),\n};\n\nreturn [\n  {\n    json: {\n      chatId,\n      telegramFileId,\n    },\n  },\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "fead012a-52f3-42df-82ad-ac5bfaf8d4f9",
      "name": "Get Telegram File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1440,
        768
      ],
      "parameters": {
        "fileId": "={{ $json.telegramFileId }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "39240820-bd8d-498d-a444-78c6f4105292",
      "name": "Create a post",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        1936,
        -256
      ],
      "parameters": {
        "text": "={{ $json.postContent }}",
        "person": "0iutWNMF-o",
        "additionalFields": {},
        "shareMediaCategory": "IMAGE"
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e6a7aaaa-2a25-4180-9b65-f4008ba80968",
      "name": "Prepare Post Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1264,
        -256
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst chatId = $('Get Saved Draft').first().json.chatId;\nconst savedDraft = data[chatId] || {};\n\nreturn [{\n  json: {\n    chatId,\n    postContent: savedDraft.postContent || '',\n    telegramFileId: savedDraft.telegramFileId || ''\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "6e90f6a6-5ebe-4541-90cf-f76e2b06c621",
      "name": "Download Image for Post",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1488,
        -256
      ],
      "parameters": {
        "fileId": "={{ $json.telegramFileId }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "40854fc6-176f-4010-acb2-009c810615da",
      "name": "Add Post Content to Image",
      "type": "n8n-nodes-base.set",
      "position": [
        1712,
        -256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "postContent",
              "type": "string",
              "value": "={{ $('Prepare Post Data').item.json.postContent }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "ee7ca075-cb47-49ed-8533-9f618aba4fc2",
      "name": "AI Intent Classifier",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -256,
        320
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "You are an intent classifier for a LinkedIn post creation assistant.\n\nAnalyze the user's message and classify it into ONE of these intents:\n\n1. **new_topic** - User wants to create a new LinkedIn post about a topic\n   Examples: \n   - \"Write about AI\"\n   - \"Create a post on leadership\"\n   - \"I want to post about productivity\"\n   - \"Please draft a post about remote work\"\n   - \"Please create a post on entrepreneurship\"\n   - \"Please write about mental health\"\n   - \"Draft a post on innovation\"\n   - \"Write a post about team building\"\n   - \"Can you write about digital marketing?\"\n   - \"I'd like a post on customer service\"\n\n2. **generate_image** - User wants to generate an AI image for their post\n   Examples: \"Create an image of...\", \"Generate a picture showing...\", \"I need an image with...\"\n\n3. **approve_image** - User approves the generated/uploaded image\n   Examples: \"approve image\", \"use this image\", \"looks good\", \"yes use it\"\n\n4. **approve_post** - User approves the post to publish\n   Examples: \"approve\", \"post it\", \"publish\", \"looks good post it\", \"yes\"\n\n5. **revise_post** - User provides feedback to revise the post\n   Examples: \"make it shorter\", \"add more emotion\", \"change the tone\", \"can you make it more professional\"\n\n6. **cancel_reset** - User wants to cancel/reset and start over\n   Examples: \"cancel\", \"reset\", \"start over\", \"clear everything\", \"delete draft\"\n\n7. **unclear** - Message doesn't clearly match any intent\n   Examples: \"hello\", \"what?\", random text\n\nRules:\n- Be flexible with natural language variations\n- If unsure between two intents, choose the most likely one\n- Only use 'unclear' if truly ambiguous\n- Extract any relevant details (topic, image description, feedback) into the details field\n- **If the user describes a topic they want to post about (even if phrased as a request or question), classify as new_topic**\n- Any message describing a topic or asking to create/draft/write a post should be classified as new_topic\n\n---\n\n## \u26a0\ufe0f Important Limitations\n\nThis assistant can help you:\n\u2705 Create new LinkedIn posts on any topic\n\u2705 Generate AI images for posts\n\u2705 Revise and refine post drafts\n\u2705 Approve and publish posts (with or without images)\n\n\u274c This assistant CANNOT:\n- Retrieve or view your previous LinkedIn posts\n- Edit already published posts\n- Delete posts from LinkedIn\n- Access your LinkedIn analytics or engagement data\n\nIf the user asks to retrieve, view, edit, or delete previous posts, classify as 'unclear' intent and the details field should contain 'retrieve_previous_posts_not_supported'."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "be694179-bb73-4b3c-80f9-03428cecac74",
      "name": "Intent Classification Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -256,
        544
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4",
          "cachedResultName": "gpt-4"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "71973d31-cf0d-4eaa-b0ef-ac514709f545",
      "name": "Intent Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -128,
        576
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"intent\": {\n      \"type\": \"string\",\n      \"enum\": [\"new_topic\", \"generate_image\", \"approve_image\", \"approve_post\", \"revise_post\", \"cancel_reset\", \"unclear\"],\n      \"description\": \"The classified intent\"\n    },\n    \"details\": {\n      \"type\": \"string\",\n      \"description\": \"Extracted topic, image description, or feedback details\"\n    },\n    \"confidence\": {\n      \"type\": \"string\",\n      \"enum\": [\"high\", \"medium\", \"low\"],\n      \"description\": \"Confidence level of the classification\"\n    }\n  },\n  \"required\": [\"intent\", \"details\", \"confidence\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "68d34f0d-81db-43c2-b063-f4e52b9b82d7",
      "name": "Route by Intent",
      "type": "n8n-nodes-base.switch",
      "position": [
        96,
        240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "New Topic",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "intent-new-topic",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.intent }}",
                    "rightValue": "new_topic"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Generate Image",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "intent-generate-image",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.intent }}",
                    "rightValue": "generate_image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Approve Image",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "intent-approve-image",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.intent }}",
                    "rightValue": "approve_image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Approve Post",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "intent-approve-post",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.intent }}",
                    "rightValue": "approve_post"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Revise Post",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "intent-revise-post",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.intent }}",
                    "rightValue": "revise_post"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Cancel/Reset",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "intent-cancel-reset",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.intent }}",
                    "rightValue": "cancel_reset"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5737e07a-8348-401a-8e8f-329908db574a",
      "name": "Prepare Topic from AI Intent",
      "type": "n8n-nodes-base.code",
      "position": [
        528,
        128
      ],
      "parameters": {
        "jsCode": "const chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst details = $json.output.details || '';\n\nreturn [{\n  json: {\n    chatId,\n    topic: details,\n  },\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "14511896-cf06-4b47-9821-426aa0154062",
      "name": "Prepare Image Prompt from AI Intent",
      "type": "n8n-nodes-base.code",
      "position": [
        512,
        800
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst imagePrompt = $json.output.details || '';\n\nconst existing = data[chatId] || {};\n\ndata[chatId] = {\n  ...existing,\n  imageStatus: 'pending',\n  imageApproved: false,\n  imageSource: 'ai',\n  imagePrompt,\n  updatedAt: new Date().toISOString(),\n};\n\nreturn [{\n  json: {\n    chatId,\n    imagePrompt,\n    imageStatus: 'pending',\n    imageApproved: false,\n    imageSource: 'ai',\n  },\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7d0dfe0b-1aad-4fcb-8702-0df560dd9a76",
      "name": "Prepare Feedback from AI Intent",
      "type": "n8n-nodes-base.code",
      "position": [
        528,
        448
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\nconst feedback = $json.output.details || '';\n\nconst savedDraft = data[chatId] || {};\n\nreturn [{\n  json: {\n    chatId,\n    feedback,\n    currentDraft: savedDraft.postContent || '',\n    status: savedDraft.status || '',\n  },\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "adc4d089-0a91-4231-9b64-897ed4d3dcb0",
      "name": "Handle Unclear Intent",
      "type": "n8n-nodes-base.telegram",
      "position": [
        544,
        1664
      ],
      "parameters": {
        "text": "={{ $json.output.details === 'retrieve_previous_posts_not_supported' ? \"\u274c *Feature Not Available*\\n\\nI cannot retrieve, view, or edit your previous LinkedIn posts. This workflow only helps you create and publish NEW posts.\\n\\nWhat I CAN help you with:\\n\\n\ud83d\udcdd *Create a post:*\\n\u2022 Tell me the topic (e.g., \\\"Write about AI in healthcare\\\")\\n\\n\ud83d\uddbc\ufe0f *Add an image:*\\n\u2022 Describe the image (e.g., \\\"Create an image of a futuristic city\\\")\\n\\n\u2705 *Approve:*\\n\u2022 Say \\\"approve\\\" to publish the post\\n\u2022 Say \\\"approve image\\\" to confirm the image\\n\\n\u270f\ufe0f *Revise:*\\n\u2022 Give feedback (e.g., \\\"make it shorter\\\" or \\\"add more emotion\\\")\\n\\n\ud83d\udd04 *Start Over:*\\n\u2022 Say \\\"cancel\\\" or \\\"reset\\\" to clear everything and start fresh\" : \"I'm not sure what you'd like me to do. Here are the available commands:\\n\\n\ud83d\udcdd *Create a post:*\\n\u2022 Just tell me the topic (e.g., \\\"Write about AI in healthcare\\\")\\n\\n\ud83d\uddbc\ufe0f *Add an image:*\\n\u2022 Describe the image you want (e.g., \\\"Create an image of a futuristic city\\\")\\n\\n\u2705 *Approve:*\\n\u2022 Say \\\"approve\\\" to publish the post\\n\u2022 Say \\\"approve image\\\" to confirm the image\\n\\n\u270f\ufe0f *Revise:*\\n\u2022 Give me feedback (e.g., \\\"make it shorter\\\" or \\\"add more emotion\\\")\\n\\n\ud83d\udd04 *Start Over:*\\n\u2022 Say \\\"cancel\\\" or \\\"reset\\\" to clear everything and start fresh\" }}",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0d1807f4-32f6-4df7-94d7-8cafd35c1fba",
      "name": "Clear Post Data After Text Post",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        -448
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst chatId = $('Get Saved Draft').first().json.chatId;\n\n// Clear the post data after successful posting\ndelete data[chatId];\n\nreturn [{ json: { chatId, cleared: true } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "151c02d3-92a8-42c8-ac78-a9cf1d3e74ea",
      "name": "Clear Post Data After Image Post",
      "type": "n8n-nodes-base.code",
      "position": [
        2160,
        -256
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst chatId = $('Get Saved Draft').first().json.chatId;\n\n// Clear the post data after successful posting\ndelete data[chatId];\n\nreturn [{ json: { chatId, cleared: true } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "82c5476d-17ce-43e3-b77f-302a66ec4e90",
      "name": "Daily Cleanup Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -288,
        1008
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 2
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3d30461d-8a29-4e01-9e7c-dd02e6f59115",
      "name": "Clean Abandoned Drafts",
      "type": "n8n-nodes-base.code",
      "position": [
        -64,
        1008
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst now = new Date();\nconst maxAgeHours = 48; // Clean drafts older than 48 hours\nlet cleanedCount = 0;\n\nfor (const chatId in data) {\n  const draft = data[chatId];\n  if (draft.updatedAt) {\n    const draftAge = (now - new Date(draft.updatedAt)) / (1000 * 60 * 60);\n    if (draftAge > maxAgeHours) {\n      delete data[chatId];\n      cleanedCount++;\n    }\n  }\n}\n\nreturn [{\n  json: {\n    cleanedCount,\n    timestamp: now.toISOString(),\n    message: `Cleaned ${cleanedCount} abandoned drafts older than ${maxAgeHours} hours`\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "15afe64c-5e40-4fcb-a8a5-2b2e77fb013a",
      "name": "Reset User Session",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        1840
      ],
      "parameters": {
        "jsCode": "const data = $getWorkflowStaticData('global');\nconst chatId = $('Telegram Trigger').first().json.message.chat.id.toString();\n\n// Clear all data for this user\ndelete data[chatId];\n\nreturn [{\n  json: {\n    chatId,\n    reset: true,\n    message: 'Session reset successfully'\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "aae176cb-63df-4dba-a310-b75b7c3da6fd",
      "name": "Confirm Reset",
      "type": "n8n-nodes-base.telegram",
      "position": [
        848,
        1840
      ],
      "parameters": {
        "text": "=\ud83d\udd04 *Session Reset*\n\nAll your drafts and images have been cleared. You can start fresh!\n\nSend me a topic to create a new LinkedIn post.",
        "chatId": "={{ $json.chatId }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d397887e-cc21-4899-a9a8-b758cbc960b6",
      "name": "Main Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        0
      ],
      "parameters": {
        "width": 420,
        "height": 864,
        "content": "# \ud83e\udd16 AI LinkedIn Post Assistant with Telegram\n\n## What This Workflow Does\nCreate professional LinkedIn posts through natural conversation with your Telegram bot. The AI generates content, creates images with DALL-E 3, and publishes directly to LinkedIn\u2014all from your phone.\n\n**How It Works:**\n1. Message your bot with a topic (e.g., \"Write about AI in healthcare\")\n2. Review the AI-generated draft\n3. Optional: Request an AI image or provide feedback for revisions\n4. Say \"approve\" to publish to LinkedIn\n\n## Setup Instructions\n\u2610 **Create Telegram Bot:** Message @BotFather on Telegram, send `/newbot`, and copy your bot token\n\u2610 **Add Credentials:** Configure Telegram API, LinkedIn OAuth2, and OpenAI API credentials in n8n\n\u2610 **Activate Workflow:** Save and toggle to Active\n\u2610 **Test:** Message your bot with a topic to verify it works\n\n## Customization\n\u2022 **Adjust AI tone:** Edit the \"LinkedIn Post Generator\" system message for different writing styles\n\u2022 **Change cleanup schedule:** Modify \"Daily Cleanup Schedule\" (default: 2 AM daily, 48-hour retention)\n\u2022 **Customize responses:** Edit Telegram message nodes to change bot replies\n\n**Commands:** Just chat naturally say \"approve\", \"approve image\", \"cancel\", or provide feedback like \"make it shorter\""
      },
      "typeVersion": 1
    },
    {
      "id": "be767fc1-2dfc-43b1-989c-0424d7679679",
      "name": "Section: Post Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 1096,
        "height": 664,
        "content": "## \u270d\ufe0f Post Generation & Revision\n\n1st Draft: GPT-4 creates LinkedIn posts based on user topics, saves drafts to workflow memory, and sends previews via Telegram.\n\nRevision: Users provide feedback to refine posts. AI revises content while preserving approved images and conversation context."
      },
      "typeVersion": 1
    },
    {
      "id": "a876e9e3-6667-4f80-8792-89020e236383",
      "name": "Section: Image Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        672
      ],
      "parameters": {
        "color": 7,
        "width": 1176,
        "height": 872,
        "content": "## \ud83d\uddbc\ufe0f Image Generation & Approval\nDALL-E 3 creates professional images based on user descriptions. Images are previewed in Telegram and require approval before posting."
      },
      "typeVersion": 1
    },
    {
      "id": "21ee1679-6047-4b8d-8893-698f31b2d630",
      "name": "Section: Publishing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -656
      ],
      "parameters": {
        "color": 7,
        "width": 2136,
        "height": 600,
        "content": "## \ud83d\udce4 Publishing to LinkedIn\nWhen user approves, posts are published to LinkedIn with or without images. Session data is cleared after successful posting."
      },
      "typeVersion": 1
    },
    {
      "id": "f62acbd7-0083-47bd-9324-74c53b1b10ca",
      "name": "Section: Maintenance",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        848
      ],
      "parameters": {
        "color": 4,
        "width": 552,
        "height": 312,
        "content": "## \ud83e\uddf9 Automatic Cleanup\nDaily schedule removes abandoned drafts older than 48 hours to prevent memory bloat. Users can also manually reset with \"cancel\" command."
      },
      "typeVersion": 1
    },
    {
      "id": "946aa66a-1bce-4be3-a9ee-8dedc9784575",
      "name": "Section: Intent Classification",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 312,
        "height": 536,
        "content": "## \ud83c\udfaf Intent Classification\nAI analyzes user messages to determine intent (new post, image generation, approval, revision, or cancel) and routes to the appropriate handler."
      },
      "typeVersion": 1
    },
    {
      "id": "8e2d5a65-4ee3-42ea-bad0-1f256bf96ed3",
      "name": "Section: Maintenance1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        1568
      ],
      "parameters": {
        "color": 7,
        "width": 552,
        "height": 424,
        "content": "## Fallback & Reset the Seession"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "ee3cd035-7e7c-4f3d-b73a-d90703db9f24",
  "connections": {
    "Save Draft": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approve Image": {
      "main": [
        [
          {
            "node": "Check Image Approval Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a post": {
      "main": [
        [
          {
            "node": "Clear Post Data After Image Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save AI Image": {
      "main": [
        [
          {
            "node": "Send a photo message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Text Only": {
      "main": [
        [
          {
            "node": "Clear Post Data After Text Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Saved Draft": {
      "main": [
        [
          {
            "node": "Check Final Post Readiness",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Intent": {
      "main": [
        [
          {
            "node": "Prepare Topic from AI Intent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Image Prompt from AI Intent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Approve Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Saved Draft",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Feedback from AI Intent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Unclear Intent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Reset User Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Intent Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Image": {
      "main": [
        [
          {
            "node": "Save AI Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Telegram File": {
      "main": [
        []
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "LinkedIn Post Generator",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Revise LinkedIn Post",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Post Data": {
      "main": [
        [
          {
            "node": "Download Image for Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Image Status": {
      "main": [
        [
          {
            "node": "Prepare Post Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post Text Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Create Image Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Reset User Session": {
      "main": [
        [
          {
            "node": "Confirm Reset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Revised Draft": {
      "main": [
        [
          {
            "node": "Send Revised Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "LinkedIn Post Generator",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Revise LinkedIn Post",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Create Image Prompt": {
      "main": [
        [
          {
            "node": "Generate AI Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Intent Classifier": {
      "main": [
        [
          {
            "node": "Route by Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Intent Classifier",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Revise LinkedIn Post": {
      "main": [
        [
          {
            "node": "Save Revised Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a photo message": {
      "main": [
        [
          {
            "node": "Save Telegram Image File ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm Image Approval": {
      "main": [
        []
      ]
    },
    "Daily Cleanup Schedule": {
      "main": [
        [
          {
            "node": "Clean Abandoned Drafts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image for Post": {
      "main": [
        [
          {
            "node": "Add Post Content to Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LinkedIn Post Generator": {
      "main": [
        [
          {
            "node": "Save Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Post Content to Image": {
      "main": [
        [
          {
            "node": "Create a post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Final Post Readiness": {
      "main": [
        [
          {
            "node": "Image Not Approved Warning",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Image Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Image Approval Result": {
      "main": [
        [
          {
            "node": "Confirm Image Approval",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Image Approval Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Classification Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Intent Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Save Telegram Image File ID": {
      "main": [
        [
          {
            "node": "Get Telegram File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Topic from AI Intent": {
      "main": [
        [
          {
            "node": "LinkedIn Post Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clear Post Data After Text Post": {
      "main": [
        [
          {
            "node": "Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Feedback from AI Intent": {
      "main": [
        [
          {
            "node": "Revise LinkedIn Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clear Post Data After Image Post": {
      "main": [
        [
          {
            "node": "Confirmation With Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Image Prompt from AI Intent": {
      "main": [
        [
          {
            "node": "Create Image Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}