{
  "nodes": [
    {
      "id": "e3517ee8-ff96-4a9c-8000-789edfde137f",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -816,
        112
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3493a02f-74b5-4f47-a65c-d29270527f2d",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        48,
        -48
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "result.data.results"
      },
      "typeVersion": 1
    },
    {
      "id": "56bf0f72-13b6-4dbb-9076-21d2dcaf2147",
      "name": "generate_img",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -192,
        -48
      ],
      "parameters": {
        "url": "https://ai-text-to-image-generator-flux-free-api.p.rapidapi.com/aaaaaaaaaaaaaaaaaiimagegenerator/quick.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.output.img_prompt }}"
            },
            {
              "name": "style_id",
              "value": "4"
            },
            {
              "name": "size",
              "value": "1-1"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "ai-text-to-image-generator-flux-free-api.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "YOUR_RAPID_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "14334c13-43d4-457f-904e-127f3b0fff08",
      "name": "download_img",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        288,
        -48
      ],
      "parameters": {
        "url": "={{ $json.thumb }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "4b98d03e-15fa-4cf9-8fba-d614059bb22c",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -416,
        720
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-nano",
          "cachedResultName": "gpt-5-nano"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "92b864a4-898d-4780-bc89-b89438b6b7bb",
      "name": "tavily",
      "type": "@tavily/n8n-nodes-tavily.tavilyTool",
      "position": [
        -128,
        640
      ],
      "parameters": {
        "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Query', ``, 'string') }}",
        "options": {
          "days": 3,
          "topic": "general",
          "max_results": 5,
          "search_depth": "advanced"
        }
      },
      "credentials": {
        "tavilyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "db0412c2-37c4-4256-9a42-580f089284b1",
      "name": "expert_algo",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -576,
        112
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=Tu es un expert en algorythme LinkedIn. Tu es capable d'analyser les meilleurs posts viraux, et comprendre pourquoi ils ont \u00e9t\u00e9 viraux. \n\nTa mission est d'analyser tout les posts LinkedIn qui ont le plus d'impressions et de r\u00e9actions en rapport avec la demande de l'utilisateur, et d'envoyer en output un framework pertinent pour cr\u00e9er un post viral destin\u00e9 \u00e0 \u00eatre publier et un prompt pour g\u00e9n\u00e9rer une image pour le post !\n\nR\u00e8gles :\n- Utilise ton outil de recherche \"tavily\" pour surveiller les posts LinkedIn viraux. \n- Ta r\u00e9ponse doit \u00eatre bien structur\u00e9 avec un framework exploitable.\n\nFormat de r\u00e9ponse : \n{\n  \"framework\": \"Framework exploitable pour r\u00e9diger le post LinkedIn\",\n  \"img_prompt\": \"Prompt exploitable pour g\u00e9n\u00e9rer l'image pous le post\"\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "04e2ae49-6ee9-469f-8318-484a1b605460",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -432,
        208
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"framework\": \"string\",\n  \"img_prompt\": \"string\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "63c2485f-0186-4126-a83e-27046efbb96d",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -48,
        336
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"post_1\": \"string\",\n  \"post_2\": \"string\",\n  \"post_3\": \"string\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "34fb849d-522e-40aa-bda4-3bd72c70d60c",
      "name": "Community Manager",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        160,
        240
      ],
      "parameters": {
        "text": "=Voici les 3 proposition de post : \n1 : \n{{ $json.output.post_1 }}\n2 : \n{{ $json.output.post_2 }}\n3 : \n{{ $json.output.post_3 }}",
        "options": {
          "systemMessage": "=Tu es un Community Manager s\u00e9nior, ta mission est d'analyser les 3 propositions de posts LinkedIn que tu re\u00e7ois en input, et de choisir celui qui te semble le plus viral et le transmet dans ton output. \n\nR\u00e8gles :\n- Utilise ton outil tavily pour effectuer les recherches n\u00e9cessaires pour savoir quelle proposition de post serai la plus virale.\n- Format de r\u00e9ponse : \n{\n  \"post\": \"Post LinkedIn choisi\"\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "a21e029e-b5b1-468b-937a-5952c0d405f3",
      "name": "CM Junior",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -192,
        240
      ],
      "parameters": {
        "text": "=Voici le framework \u00e0 utiliser :\n{{ $json.output.framework }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=Tu es expert en r\u00e9daction de post LinkedIn viral, tu es community manager s\u00e9nior et les algorithmes des r\u00e9seaux sociaux n'ont plus aucun secret pour toi \n\nTa mission est de me proposer 3 posts LinkedIn viral gr\u00e2ce au framework que tu re\u00e7ois en input. \n\nR\u00e8gles : \n- Les posts LinkedIn doivent faire entre 500 et 900 caract\u00e8res\n- Ton style de r\u00e9daction doit imp\u00e9rativement refl\u00e9ter le mien : ton amical et instructif. \n- Utilise imp\u00e9rativement le framework pour r\u00e9diger tes propositions de posts LinkedIn. \n\nFormat de r\u00e9ponse : \n\n{\n  \"post_1\": \"Premi\u00e8re proposition de post\",\n  \"post_2\": \"Deuxi\u00e8me proposition de post\",\n  \"post_3\": \"Troisi\u00e8me proposition de post\"\n}"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "97507dd8-0812-4109-a669-11e59d88c438",
      "name": "Structured Output Parser2",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        304,
        336
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"post\": \"string\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "23a40733-0b6c-4289-b44d-25431f6a0923",
      "name": "Send a photo message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        496,
        -48
      ],
      "parameters": {
        "chatId": "=YOUR_TELEGRAM_CHAT_ID",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8740c71-f52e-428f-b327-a15aa9730db9",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        496,
        240
      ],
      "parameters": {
        "text": "={{ $json.output.post }}",
        "chatId": "=YOUR_TELEGRAM_CHAT_ID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "da682c59-f46b-408c-afd5-430a91a41feb",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        -288
      ],
      "parameters": {
        "width": 2240,
        "height": 1200,
        "content": "## LinkedIn Viral Content Generator & Image Poster (Telegram Bot)  \n\n### Description:  \n\nThis workflow helps you generate a viral LinkedIn post + AI image PROMPTED by user request on Telegram.  \nIt uses AI to analyze trending LinkedIn content, builds an effective framework for virality, creates post variations, selects the best one, generates an image, and sends both back on Telegram.\n\n\n---\n\n## Requirements / Setup  \n\n### Description:  \n\n- Configure your OpenAI credentials  \n- Set your Telegram credentials and chat ID  \n- Obtain your RAPIDAPI key for the free AI image generator  \n- (Optionally: Set up Tavily credentials if needed for research tools)\n\n\n---\n\n## Personalization  \n\n### Description:\n  \n\n- All authentication values must be inserted via Credentials panel, not hard-coded in nodes  \n- Edit any placeholders (e.g., chat ID, keys) before activating your workflow\n\n\n---\n\n\n## Test Before Publish  \n\n### Description:  \n\n\n- Run the workflow with your own values to ensure everything works  \n- Make sure NO sensitive/personal data remains before sharing  \n- You can add example outputs in note (markdown supports code formatting)\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "tavily": {
      "ai_tool": [
        [
          {
            "node": "expert_algo",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Community Manager",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "CM Junior": {
      "main": [
        [
          {
            "node": "Community Manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "download_img",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "expert_algo": {
      "main": [
        [
          {
            "node": "CM Junior",
            "type": "main",
            "index": 0
          },
          {
            "node": "generate_img",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "download_img": {
      "main": [
        [
          {
            "node": "Send a photo message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "generate_img": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "expert_algo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Community Manager": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "expert_algo",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "CM Junior",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Community Manager",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "expert_algo",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "CM Junior",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser2": {
      "ai_outputParser": [
        [
          {
            "node": "Community Manager",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}