{
  "id": "12HhNt7pAzQTW1T8",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI SMM manager",
  "tags": [],
  "nodes": [
    {
      "id": "92461be1-8166-4e3c-b40a-beb2ceb4924a",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -112,
        32
      ],
      "parameters": {
        "updates": [
          "message",
          "callback_query",
          "inline_query",
          "*"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bbe5809f-e74f-4c15-8628-92a35d9bb189",
      "name": "Set input context",
      "type": "n8n-nodes-base.set",
      "position": [
        160,
        32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b650c645-7341-4007-8fa3-ba4047fd694b",
              "name": "chat_id",
              "type": "string",
              "value": "={{ $json.callback_query?.message.chat.id || $json.message?.chat.id }}"
            },
            {
              "id": "af488204-9701-4974-96f2-7a403d80c3fd",
              "name": "callback_data",
              "type": "string",
              "value": "={{ $json.callback_query?.data || 'none' }}"
            },
            {
              "id": "6b624f31-898f-4a65-8f93-708da5f19fb5",
              "name": "message_text",
              "type": "string",
              "value": "={{ $json.message?.text || 'none' }}"
            },
            {
              "id": "5a609d6b-9622-44e9-ba46-8ec65b6406b7",
              "name": "update_type",
              "type": "string",
              "value": "={{ (() => {\n    if ($json.message?.text) {\n        return 'text';\n    } else if ($json.callback_query?.data) {\n        return 'callback';\n    } else if ($json.message?.document) {\n        return 'document';\n    } else if ($json.message?.voice) {\n        return 'voice'\n    } else {\n        return 'unknown';\n    }\n})() }}"
            },
            {
              "id": "3a0c9536-5fa0-482a-bb6d-1d40b8d04030",
              "name": "file_id",
              "type": "string",
              "value": "={{ $json.message.document?.file_id }}"
            },
            {
              "id": "b7fff404-3337-4838-84b5-2433864556c0",
              "name": "file_mime_type",
              "type": "string",
              "value": "={{ $json.message.document?.mime_type }}"
            },
            {
              "id": "b1a25c86-41f3-4ec3-9dc7-05afa171fd3e",
              "name": "file_caption",
              "type": "string",
              "value": "={{ $json.message.caption }}"
            },
            {
              "id": "69c5db95-7d08-49a6-8c17-e941e23107dd",
              "name": "voice_file_id",
              "type": "string",
              "value": "={{ $json.message.voice.file_id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9281e1e8-c019-4479-bedb-37e3e6d72a39",
      "name": "Text prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        -256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ff244c43-de08-4f20-8b5c-077b6ce1e6ca",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $('Set input context').item.json.message_text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3f470d9f-755a-4aaf-9573-f14162517de6",
      "name": "Document prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        -64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ff244c43-de08-4f20-8b5c-077b6ce1e6ca",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $('Set input context').item.json.file_caption }}\n\n--- Information extracted from document sent by the user ---\n{{ $json.candidates[0].content.parts[0].text }}\n--- End for information extracted from document sent by the user ---"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "86552b5d-5ff6-4cb8-afbc-8765a4bd6c17",
      "name": "Describe audio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        128
      ],
      "parameters": {
        "url": "=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\":[\n      {\"text\": \"Generate a transcript of the speech.\"},\n      {\n        \"inline_data\": {\n          \"mime_type\": \"audio/ogg\",\n          \"data\": \"{{ $json.data }}\"\n        }\n      }\n    ]\n  }]\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7f1ff2b5-1117-46aa-846b-f2971fe4dd1d",
      "name": "Audio prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ff244c43-de08-4f20-8b5c-077b6ce1e6ca",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.candidates[0].content.parts[0].text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "36e799c4-84ce-48e8-85ba-50f69d6f7062",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2144,
        -64
      ],
      "parameters": {
        "options": {
          "systemMessage": "Act as a content manager specializing in social media management, public relations, and network management. Your role involves several key responsibilities when a user requests to create a social media post.\nYour output should be not use Markdown, HTML or anything else. Your responses will be passed as text messages to the user.\n\n- **Understand User Input**: First, clearly understand the user's request regarding the content they wish to post on their social networks. Gather necessary details and context from the user to ensure the post is accurate and aligned with their goals.\n\n- **Context Collection**: If additional context is needed, and not provided, ask the user specific and targeted questions to obtain any missing information. Use the \"get_context_records\" tool to fetch existing records and the \"save_context_record\" tool to store any new information.\n\n- **Post Creation**: Use the provided information to create a draft social media post. This includes formulating engaging and relevant content tailored to the user's specified platform and audience.\n\n- **User Approval Process**: Present the draft to the user for feedback and approval. Never post anything without explicit user's approval!\n\n- **Posting**: After receiving approval from the user, post the content using the corresponding social media tools."
        }
      },
      "typeVersion": 2
    },
    {
      "id": "833e1b25-b348-4cca-b4b7-c8661e97cf57",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1664,
        160
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3b96b10d-ce34-454f-b6fb-6a0e41724a79",
      "name": "Embeddings Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        1904,
        416
      ],
      "parameters": {
        "modelName": "models/embedding-001"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fa334f34-fa5f-45f4-bb08-69db605d4d40",
      "name": "Send response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3280,
        -64
      ],
      "parameters": {
        "text": "={{ $json.parts || \"Error occured, pls try again\" }}",
        "chatId": "={{ $('Set input context').item.json.chat_id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "53e4a542-3608-416e-8703-1344f1485d5d",
      "name": "Create X (Twitter) post",
      "type": "n8n-nodes-base.twitterTool",
      "position": [
        2512,
        448
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "descriptionType": "manual",
        "toolDescription": "Create Tweet in X. Text must be 280 characters or less. If you receive \"Forbidden\" error, it means that the text is too long, you need to shorted it.",
        "additionalFields": {}
      },
      "credentials": {
        "twitterOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "4226e081-af3f-42ea-ba06-caef96e9448a",
      "name": "Chat Memory Manager",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        832,
        320
      ],
      "parameters": {
        "mode": "delete",
        "deleteMode": "all"
      },
      "typeVersion": 1.1
    },
    {
      "id": "6b7a925f-c111-4b4f-b1d5-2fcd3d9ae3ac",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        608,
        416
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b9045645-8715-47b5-82b1-2793c1618000",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Set input context').item.json.callback_data }}",
              "rightValue": "cm"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3b056078-970e-4907-87df-9d3c6f5b5cbf",
      "name": "Error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        928,
        512
      ],
      "parameters": {
        "text": "Invalid callback",
        "chatId": "={{ $('Set input context').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d58fd416-cfb1-48b9-86cf-de6e5ca9c571",
      "name": "Success",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1232,
        320
      ],
      "parameters": {
        "text": "Memory is cleaned",
        "chatId": "={{ $('Set input context').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9b86684f-9018-4c48-b09f-4d9d6895731b",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1792,
        160
      ],
      "parameters": {
        "sessionKey": "={{ $('Set input context').item.json.chat_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a92792e9-a558-47a9-977d-16d57f47e160",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        3056,
        -64
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "parts"
      },
      "typeVersion": 1
    },
    {
      "id": "2c253f28-1cc6-49f9-85b2-4b4f80979670",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -192
      ],
      "parameters": {
        "color": 2,
        "width": 224,
        "height": 416,
        "content": "## Bot entrance\n\nSet your Telegram bot credentials here.\n\nOptional: add \"Restrict to chat IDs\" with your chat ID so that only you can use your bot"
      },
      "typeVersion": 1
    },
    {
      "id": "6b879d47-c143-41cf-91d1-f7fb86cb4253",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -192
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 416,
        "content": "## Request preprocessing\n\nSetting fields from the request to a more convinient format"
      },
      "typeVersion": 1
    },
    {
      "id": "3aea91ae-f5b7-4107-baa4-cab71e530ea5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -288
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 576,
        "content": "## Extracting data from non-text input\n\nSet up \"Describe PDF\" and \"Describe audio\" nodes with Google's AI Studio API key\n\nSet up \"Download document\" and \"Download audio\" with Telegram Bot API key"
      },
      "typeVersion": 1
    },
    {
      "id": "dd2efbf5-9ba0-4f45-b3ae-8d38ce112d5c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        -400
      ],
      "parameters": {
        "color": 2,
        "width": 384,
        "height": 496,
        "content": "## AI Agent Node\n\n**Needs setup**\n\nAdd your Google's AI Studio API key to the \"Model\" node\n\nHere the agent receives the user's input and decides what to do it response:\n- Ask for clarification\n- Prepare the post and send for verification\n- Create a post in LinkedIn or X\n- Save some information in long-term memory"
      },
      "typeVersion": 1
    },
    {
      "id": "ce006594-4ad4-4bda-86d3-e2ffb6bc919b",
      "name": "Split agent's response",
      "type": "n8n-nodes-base.code",
      "position": [
        2832,
        -64
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfunction splitString(str, size) {\n  let result = [];\n  for (let i = 0; i < str.length; i += size) {\n    result.push(str.slice(i, i + size));\n  }\n  return result;\n}\n\nfor (const item of $input.all()) {\n  const parts = splitString(item.json.output, 3000)\n  item.json.parts = parts;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "5243247e-0d99-49f0-95b9-9b338b839053",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2768,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "height": 320,
        "content": "## Response to the user\nHere we optionally split the agent's response into multiple messages not to get \"Message too long\" error from Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "a41942b8-88d9-4fb9-a70a-2b9b23ba1619",
      "name": "Input type switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        384,
        -16
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9f54c101-20a1-45f2-b154-d9e4456cf906",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.update_type }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "document",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9c2293ff-0921-4c5e-94c0-953a7e613737",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.update_type }}",
                    "rightValue": "document"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bc8ad42b-6051-4145-9c00-8984a63d285a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.update_type }}",
                    "rightValue": "voice"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "callback",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "07580596-c93b-41a0-8dfe-3c4a8f364fb6",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.update_type }}",
                    "rightValue": "callback"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "9a790d0b-62fb-47c0-8670-2d33433140f9",
      "name": "Encode document",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        928,
        -64
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "51e25ea9-1463-44f3-a2ce-8b1a89ada8b2",
      "name": "Encode audio",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        928,
        128
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "a2fee96e-5619-44ed-afd6-a0cd84c86bcb",
      "name": "Describe document",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        -64
      ],
      "parameters": {
        "url": "=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\":[\n      {\"text\": \"Exctract all the information about the company or product from this document\"},\n      {\n        \"inline_data\": {\n          \"mime_type\": \"{{$('Download document').item.binary.data.mimeType}}\",\n          \"data\": \"{{ $json.data }}\"\n        }\n      }\n    ]\n  }]\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "117dda5b-cad8-4f5e-8694-12d21719528d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2688,
        208
      ],
      "parameters": {
        "color": 2,
        "width": 368,
        "height": 400,
        "content": "## LinkedIn Tools\n\n- Input your organisation URN in the \"Create post in LinkedIn as a company\" node\n- Select your user name in LinkedIn in the \"Create a post in LinkedIn as a person\" "
      },
      "typeVersion": 1
    },
    {
      "id": "4f0ea1ad-15c5-4693-9afa-03dab4044aae",
      "name": "Create post in LinkedIn as a company",
      "type": "n8n-nodes-base.linkedInTool",
      "position": [
        2912,
        448
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "postAs": "organization",
        "descriptionType": "manual",
        "toolDescription": "Create a post in LinkedIn as a company",
        "additionalFields": {}
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3ccbae0c-ff7a-4ec5-8dbe-6dc23560412e",
      "name": "Create post in LinkedIn as a person",
      "type": "n8n-nodes-base.linkedInTool",
      "position": [
        2752,
        448
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "person": "NAOnogS86v",
        "descriptionType": "manual",
        "toolDescription": "Create a post in LinkedIn as a person",
        "additionalFields": {}
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fde65067-e098-4645-9c4a-d91cc3b6c669",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -416
      ],
      "parameters": {
        "width": 624,
        "height": 896,
        "content": "## Your personal AI SMM manager inside Telegram bot \n\nThis is a Telegram Bot capable of receiving info from the user in the format of text messages, voice messages or documents (i.e. presentations) and publishing posts to the user's social platforms.\n\n### Bot's behavior\n- Bot always sends user a draft of the post for verification before publishing it\n- Bot saves relevant information to it's long-term memory (vector store) so that you don't need to repeat it in every interaction (i.e. who are you, your company, product, etc.)\n\n### How it works\nEvery non-text messages gets encoded in base64 and passed to Gemini API to extract information for it.\nAI Agent gets user's input and takes neccessary actions: saves relevant information to long-term memory, prepared posts or creates posts in social networks.\nAgent's response is passed to the user as bot's response. \n\n### Requirements\nTo use this template your will need:\n1. Google's AI Studio API key. Get one here: https://aistudio.google.com/app/apikey\n2. Telegram Bot API key. You receive one when you register a new Telegram Bot via @BotFather bot in Telegram.\n3. LinkedIn API key. Follow the instructions here to create one: https://docs.n8n.io/integrations/builtin/credentials/linkedin/\n4. X API key. Follow the instructions here to create one: https://docs.n8n.io/integrations/builtin/credentials/twitter/\n\n### Step-by-step instruction\n1. Import this template\n2. Create a new Telegram Bot or get an API key for existing one.\n3. Configre Telegram nodes with Telegram API key.\n4. Obtain a Google's AI Studio API key. Set it in \"Describe document\", \"Describe audio\" and \"Google Gemini Chat Model\".\n5. Create an API key for LinkedIn.\n6. Create an API key for X.\n7. Set our LinkedIn key in \"Create post in LinkedIn\" nodes.\n8. Set your X key in \"Create X (Twitter) post\" node."
      },
      "typeVersion": 1
    },
    {
      "id": "97d54d2a-c724-4c2e-b332-e04adce6fb27",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        496
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 80,
        "content": "**Notes of this color describe information that need's to be set before launching the template - please take a look!**"
      },
      "typeVersion": 1
    },
    {
      "id": "abe22327-c5b1-40f8-8933-f850f9673b8c",
      "name": "Retrieve knowledge",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        1920,
        160
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "memoryKey": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set input context').item.json.chat_id }}"
        },
        "toolDescription": "Get knowledge records"
      },
      "typeVersion": 1.3
    },
    {
      "id": "390ea20a-8097-4bfe-97fc-adf1b4fdb5c9",
      "name": "Save knowledge",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        2240,
        160
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "1QHDXNbD3s3eRjlc",
          "cachedResultName": "Save Vector store record"
        },
        "description": "Call this tool to save some knowledge received from the user. Pass what you want to save in \"data\" parameter.",
        "workflowInputs": {
          "value": {
            "data": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('data', `The record you want to save to database`, 'string') }}",
            "chat_id": "={{ $('Set input context').item.json.chat_id }}"
          },
          "schema": [
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8372b8b0-c751-4623-8952-552019461fe0",
      "name": "Download audio",
      "type": "n8n-nodes-base.telegram",
      "position": [
        720,
        128
      ],
      "parameters": {
        "fileId": "={{ $json.voice_file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "78db4c04-44d5-4f21-860d-2dc7d556b553",
      "name": "Download document",
      "type": "n8n-nodes-base.telegram",
      "position": [
        720,
        -64
      ],
      "parameters": {
        "fileId": "={{ $json.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "92757552-9e74-4736-9182-41f740fc21e1",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Chat Memory Manager",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Split agent's response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Send response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text prompt": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audio prompt": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Encode audio": {
      "main": [
        [
          {
            "node": "Describe audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Chat Memory Manager",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Describe audio": {
      "main": [
        [
          {
            "node": "Audio prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download audio": {
      "main": [
        [
          {
            "node": "Encode audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save knowledge": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Document prompt": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Encode document": {
      "main": [
        [
          {
            "node": "Describe document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Set input context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Describe document": {
      "main": [
        [
          {
            "node": "Document prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download document": {
      "main": [
        [
          {
            "node": "Encode document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input type switch": {
      "main": [
        [
          {
            "node": "Text prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download document",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set input context": {
      "main": [
        [
          {
            "node": "Input type switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve knowledge": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory Manager": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split agent's response": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create X (Twitter) post": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini": {
      "ai_embedding": [
        [
          {
            "node": "Retrieve knowledge",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create post in LinkedIn as a person": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create post in LinkedIn as a company": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}