{
  "name": "🤖💬 Conversational AI Chatbot with Google Gemini for Text & Image | Telegram",
  "nodes": [
    {
      "id": "3017950d-52a5-4f51-a64d-7f223c01743e",
      "name": "chatPrompt",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        -880
      ]
    },
    {
      "id": "975f1ebd-9af9-4bc5-8cec-6c3be3d3a63d",
      "name": "otherPrompt",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        -720
      ]
    },
    {
      "id": "f297c8ce-7c7c-4011-9c36-e4993dbfd926",
      "name": "generatePrompt",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        -1040
      ]
    },
    {
      "id": "51eb4b31-0099-4886-9dfd-dc9c02107562",
      "name": "buildPrompt",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        -880
      ]
    },
    {
      "id": "d9a263b3-9078-47e9-8146-abf62100af21",
      "name": "ChatCore",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        280,
        -880
      ]
    },
    {
      "id": "67e27375-a9f9-45d7-8ea9-aad5d18996de",
      "name": "GeminiModel",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        300,
        -720
      ]
    },
    {
      "id": "58ab707f-00e3-4b9f-b598-af89cebf99ce",
      "name": "inputProcessor",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -460,
        -880
      ]
    },
    {
      "id": "0123eef4-eb57-485a-ad01-66dc47b332f8",
      "name": "GeminiModel1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -440,
        -740
      ]
    },
    {
      "id": "8853d1da-5ab6-44cf-8054-7267392c9eae",
      "name": "structuredOutput",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -300,
        -740
      ]
    },
    {
      "id": "b679111d-c640-4f59-8046-c37fa7f977e9",
      "name": "contentType",
      "type": "n8n-nodes-base.switch",
      "position": [
        580,
        -800
      ]
    },
    {
      "id": "8abd3463-8ecc-4086-9057-e7494b8b2d9d",
      "name": "textCleaner",
      "type": "n8n-nodes-base.code",
      "position": [
        820,
        -980
      ]
    },
    {
      "id": "a11a2afc-71c4-4b3f-81ec-fb8cacc1d9f2",
      "name": "imageGeneration",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        940,
        -980
      ]
    },
    {
      "id": "ccce85bc-79f7-43ed-b649-8b1533d774a5",
      "name": "imageBuilder",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1060,
        -980
      ]
    },
    {
      "id": "4dbbf4c4-4d78-42d3-bdbc-a35a584643ff",
      "name": "sendImage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1180,
        -980
      ]
    },
    {
      "id": "8e525ff1-f403-4f7a-a281-36fb18824168",
      "name": "sendTextMessage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1180,
        -780
      ]
    },
    {
      "id": "4e0fcbad-8b6b-4c39-80ac-6aed0f8cf0fd",
      "name": "sessionData",
      "type": "n8n-nodes-base.set",
      "position": [
        -980,
        -880
      ]
    },
    {
      "id": "ea84ebc4-2932-4fd9-8771-b13a929b6ea5",
      "name": "conversationStore",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        -860,
        -880
      ]
    },
    {
      "id": "03420024-1474-4b55-a98a-e80e0826ccc7",
      "name": "memoryRetriever",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -820,
        -740
      ]
    },
    {
      "id": "28f6a639-1c50-4754-a66c-772cc3a05083",
      "name": "latestContext",
      "type": "n8n-nodes-base.code",
      "position": [
        -580,
        -880
      ]
    },
    {
      "id": "14bae45a-aafa-407f-9761-62954acabbbd",
      "name": "intentHandler",
      "type": "n8n-nodes-base.switch",
      "position": [
        -180,
        -880
      ]
    },
    {
      "id": "2f3d4931-9549-449b-8ff8-e27bf7b69e1f",
      "name": "userInput",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1100,
        -880
      ]
    },
    {
      "id": "357a258b-32a7-47c4-bcf1-f32cec025cba",
      "name": "conversationMemory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        420,
        -700
      ]
    },
    {
      "id": "f1dad098-8b9f-4160-91ab-1eb7185d51a2",
      "name": "errorPreprocessor",
      "type": "n8n-nodes-base.set",
      "position": [
        700,
        -980
      ]
    },
    {
      "id": "804fcbd3-cbc1-41d9-bbeb-40469545012f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -860,
        -1240
      ],
      "parameters": {
        "width": 380,
        "height": 680,
        "content": "### 2. Memory and Conversational Context\n\nRetrieves the necessary context to properly infer intentions.\n\n- conversationStore: stores the entire conversation history.\n\n- memoryRetriever: extracts relev"
      }
    },
    {
      "id": "4b4e8510-6b97-4b1d-afdb-916581aa539d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1220,
        -1240
      ],
      "parameters": {
        "width": 340,
        "height": 680,
        "content": "### 1. Input and Session Management\n\nReceives messages from Telegram and manages the session to maintain context.\n\n- userInput: captures the user's message.\n\n- sessionData: saves and updates the sessi"
      }
    },
    {
      "id": "6b14b58f-2e17-4cfb-baf4-3318b3fd9533",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        -1240
      ],
      "parameters": {
        "width": 700,
        "height": 680,
        "content": "### 3. Intent Processing and Prompt Generation\nAnalyzes the intention and selects appropriate prompts according to the user's intention.\n\n- inputProcessor: detects intention and type of content to sen"
      }
    },
    {
      "id": "fa4cfc3f-cdaf-4184-b183-ca31b1aa1d86",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        -1240
      ],
      "parameters": {
        "width": 300,
        "height": 680,
        "content": "### 4. Core of Generation and Conversation Management\nGenerates responses using Google Gemini, integrating context for coherence.\n\n- ChatCore: orchestrates the generation and management of the convers"
      }
    },
    {
      "id": "ce598ece-492b-4294-9aa4-ea0c6757edf2",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        -1240
      ],
      "parameters": {
        "width": 800,
        "height": 680,
        "content": "### 5. Content Classification and User Delivery\n\nDetermines the type of content and manages its delivery via Telegram.\n\n- contentType: defines the output format (text, image, etc.).\n\n- errorPreprocess"
      }
    }
  ],
  "connections": {
    "ChatCore": {
      "main": [
        [
          {
            "node": "contentType",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "userInput": {
      "main": [
        [
          {
            "node": "sessionData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "chatPrompt": {
      "main": [
        [
          {
            "node": "buildPrompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GeminiModel": {
      "ai_languageModel": [
        [
          {
            "node": "ChatCore",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "buildPrompt": {
      "main": [
        [
          {
            "node": "ChatCore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "contentType": {
      "main": [
        [
          {
            "node": "errorPreprocessor",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "sendTextMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "otherPrompt": {
      "main": [
        [
          {
            "node": "buildPrompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "sessionData": {
      "main": [
        [
          {
            "node": "conversationStore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "textCleaner": {
      "main": [
        [
          {
            "node": "imageGeneration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GeminiModel1": {
      "ai_languageModel": [
        [
          {
            "node": "inputProcessor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "imageBuilder": {
      "main": [
        [
          {
            "node": "sendImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "intentHandler": {
      "main": [
        [
          {
            "node": "generatePrompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "chatPrompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "otherPrompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "latestContext": {
      "main": [
        [
          {
            "node": "inputProcessor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "generatePrompt": {
      "main": [
        [
          {
            "node": "buildPrompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "inputProcessor": {
      "main": [
        [
          {
            "node": "intentHandler",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "imageGeneration": {
      "main": [
        [
          {
            "node": "imageBuilder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "memoryRetriever": {
      "ai_memory": [
        [
          {
            "node": "conversationStore",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "sendTextMessage": {
      "main": [
        []
      ]
    },
    "structuredOutput": {
      "ai_outputParser": [
        [
          {
            "node": "inputProcessor",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "conversationStore": {
      "main": [
        [
          {
            "node": "latestContext",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "errorPreprocessor": {
      "main": [
        [
          {
            "node": "textCleaner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "conversationMemory": {
      "ai_memory": [
        [
          {
            "node": "ChatCore",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  }
}