{
  "name": "lesson 8",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -576,
        80
      ],
      "id": "41c73fba-9069-47bb-b1a9-ce7a704ac800",
      "name": "Telegram Trigger",
      "webhookId": "843c2444-0605-4521-adb0-c40713393748",
      "credentials": {
        "telegramApi": {
          "id": "jPmCBrjkILv2EMqW",
          "name": "n8n course yefimov ai bot"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}",
        "additionalFields": {}
      },
      "id": "b4173fe3-9ade-4dc0-9550-caf9686b7b5f",
      "name": "Get Audio File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -16,
        16
      ],
      "typeVersion": 1.2,
      "webhookId": "ff854f80-64fd-4b3a-bfe4-2c3f6465c834",
      "credentials": {
        "telegramApi": {
          "id": "jPmCBrjkILv2EMqW",
          "name": "n8n course yefimov ai bot"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data",
        "options": {}
      },
      "id": "c4fc9503-d9c9-4de1-a3a0-d0d365187996",
      "name": "Transcribe Recording",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        176,
        16
      ],
      "typeVersion": 1.6,
      "credentials": {
        "openAiApi": {
          "id": "eEgVzkmfDpAC16mU",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice }}",
                    "rightValue": "",
                    "id": "b4e67e97-c178-48ed-aa47-211e0e83f137"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "audio"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "342f0883-d959-44a2-b80d-379e39c76218",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            }
          ]
        },
        "options": {}
      },
      "id": "3246cdb9-bba4-4d8b-8b94-89319c2c6404",
      "name": "Message Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        -368,
        80
      ],
      "typeVersion": 3.2
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Сообщение от пользователя: \"{{ $json.text }}\"\n\nТы — AI-Концентратор Идей.\n\nТвоя базовая роль — умный ассистент для управления идеями и задачами.\nТы общаешься как чат-бот, но твоя основная функция — работа с инструментами для управления записями.\n\nЕсли запрос не связан с управлением идеями (приветствие, общий вопрос) — отвечай кратко и по-человечески, без вызова tools.\n\nКогда пользователь просит добавить, найти, изменить или удалить идею/задачу:\n— определи его намерение и выбери соответствующий инструмент;\n— используй данные ТОЛЬКО из tools;\n— не выдумывай и не подтверждай действия, которые не были выполнены.\n\nДоступные tools:\n\nadd_idea: для создания новой записи. Требует текст идеи и, опционально, категорию.\n\nget_ideas: для получения списка записей. Может принимать фильтры (например, по категории или ключевому слову).\n\nupdate_idea: для изменения существующей записи. Требуется row_id который можно получить через get_ideas\n\ndelete_idea: для удаления записи. Требуется row_id который можно получить через get_ideas\n\nОбщие правила:\n— Если запрос пользователя неоднозначен (например, \"удали заметку\"), задай уточняющий вопрос (\"Какую именно заметку вы хотите удалить?\").\n— После успешного выполнения действия (добавление, удаление, изменение) — кратко подтверди это.\n— Не давай советов и рекомендаций, если пользователь об этом не просил.\n\nСтиль ответа:\n— кратко, по сути, без \"воды\".\n— в обычном диалоге — свободно, как чат-бот.\n\nПравила Markdown-форматирования:\n— Используй дефис (-) для списков.\n— Выделяй ключевые элементы жирным текстом: текст.\n— Разделяй логические блоки пустой строкой.\n\nЕсли запрос не по теме:\n— ответь коротко и по-человечески,\n— мягко верни разговор к управлению идеями и задачами.",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        560,
        64
      ],
      "id": "3d3cd880-7fd4-4725-9dc5-937edd38df82",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        576,
        288
      ],
      "id": "5c2c5b59-6a65-49c9-b921-ccad41831580",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5.1",
          "mode": "list",
          "cachedResultName": "gpt-5.1"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        416,
        288
      ],
      "id": "313e7688-ca93-474a-8b3d-e8c9089bb3d6",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "eEgVzkmfDpAC16mU",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s",
          "mode": "list",
          "cachedResultName": "Ideas",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        704,
        400
      ],
      "id": "078a101a-9535-4fe3-a9ea-8b8c60487ba3",
      "name": "get_ideas",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GESnd0JOf42UVmOC",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s",
          "mode": "list",
          "cachedResultName": "Ideas",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Content', ``, 'string') }}",
            "Category": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Category', ``, 'string') }}",
            "DateCreated": "={{ $now }}",
            "Deadline": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Deadline', ``, 'string') }}",
            "DateUpdated": "={{ $now }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Content",
              "displayName": "Content",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Deadline",
              "displayName": "Deadline",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "DateCreated",
              "displayName": "DateCreated",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "DateUpdated",
              "displayName": "DateUpdated",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        816,
        400
      ],
      "id": "f933fbb5-132c-4bef-9a05-67dca4695b1b",
      "name": "add_idea",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GESnd0JOf42UVmOC",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s",
          "mode": "list",
          "cachedResultName": "Ideas",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Content', `Сюда пиши саму идею`, 'string') }}",
            "Category": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Category', ``, 'string') }}",
            "Deadline": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Deadline', ``, 'string') }}",
            "row_number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('row_number__using_to_match_', `Сюда нужно обязательно вставить правильный row_number`, 'number') }}",
            "DateUpdated": "={{ $now }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Content",
              "displayName": "Content",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Deadline",
              "displayName": "Deadline",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "DateCreated",
              "displayName": "DateCreated",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "DateUpdated",
              "displayName": "DateUpdated",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        928,
        400
      ],
      "id": "701ac82d-ae5b-479e-a9dc-774c7206c827",
      "name": "update_idea",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GESnd0JOf42UVmOC",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "delete",
        "documentId": {
          "__rl": true,
          "value": "10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s",
          "mode": "list",
          "cachedResultName": "Ideas",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10T4FDfyYBI20dD5NoX7bzB_mh0OzjqUjIPpbeaGyd9s/edit#gid=0"
        },
        "startIndex": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start_Row_Number', ``, 'number') }}",
        "numberToDelete": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Number_of_Rows_to_Delete', ``, 'number') }}"
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        1024,
        400
      ],
      "id": "36fa0078-b07d-4ad6-8997-e182b02fe31a",
      "name": "delete_idea",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GESnd0JOf42UVmOC",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "chatId": "383996218",
        "text": "={{ $json.text }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        912,
        64
      ],
      "id": "7896a89f-87d3-4036-aa4f-441075c44ee3",
      "name": "Send a text message",
      "webhookId": "455ceaa5-3883-484e-be79-c92f13a03c9a",
      "credentials": {
        "telegramApi": {
          "id": "jPmCBrjkILv2EMqW",
          "name": "n8n course yefimov ai bot"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b37b48ba-8fef-4e6c-bbca-73e6c2e1e0a8",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        },
        "options": {}
      },
      "id": "fdfcf1b2-041c-45ac-8d52-44dae51c1d26",
      "name": "[SET] Text message",
      "type": "n8n-nodes-base.set",
      "position": [
        -16,
        272
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "content": "## Привет от Yefimov_AI\n\nНе забудь подписаться на Youtube и телеграм канал"
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2352,
        5760
      ],
      "id": "d97130fe-7ed7-4cf3-882e-e9073c26453b",
      "name": "Sticky Note3"
    }
  ],
  "pinData": {},
  "connections": {
    "Get Audio File": {
      "main": [
        [
          {
            "node": "Transcribe Recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe Recording": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message Router": {
      "main": [
        [
          {
            "node": "Get Audio File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "[SET] Text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Message Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "get_ideas": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "add_idea": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "update_idea": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "delete_idea": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[SET] Text message": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false,
    "timeSavedMode": "fixed",
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "8hd-Qz-eXiM9GwvkMFgju"
  },
  "versionId": "f403ae79-c20c-4e90-8ee0-738df25eb250",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "7ef81a965bb52d3c42bd218dc22fb53205bba7e12a5fda73cdb321bee53a0ffc"
  },
  "id": "xQNcbPnk5YL03A5a",
  "tags": [
    {
      "updatedAt": "2025-07-26T19:24:38.741Z",
      "createdAt": "2025-07-26T19:24:38.741Z",
      "id": "PhEU8XvMbDgCJtf7",
      "name": "yefimov_ai"
    }
  ]
}