{
  "name": "Eliza Coordinator Agent",
  "nodes": [
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -100,
        380
      ],
      "id": "faa42629-12b9-44bb-a24c-e192925248d4",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        60,
        420
      ],
      "id": "498ded4e-7fba-40ad-8f15-0b3ce3105fed",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "toolDescription": "Use this tool to search the internet",
        "method": "POST",
        "url": "https://api.tavily.com/search",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n    \"api_key\": \"your-api-key\",\n    \"query\": \"{searchTerm}\",\n    \"search_depth\": \"basic\",\n    \"include_answer\": true,\n    \"topic\": \"news\",\n    \"include_raw_content\": true,\n    \"max_results\": 3\n} ",
        "placeholderDefinitions": {
          "values": [
            {
              "name": "searchTerm",
              "description": "What the user has requested to search the internet for",
              "type": "string"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1.1,
      "position": [
        520,
        420
      ],
      "id": "7be7fe23-e791-4f8c-bfd6-d328def8c790",
      "name": "Tavily"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        680,
        380
      ],
      "id": "babc19ee-d739-4b7e-a275-b8d8fe9d61f8",
      "name": "Calculator"
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "5af21bc1-c959-48c6-a9b3-30a6ecca1dfc",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        -500,
        80
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fe7ecc99-e1e8-4a5e-bdd6-6fce9757b234",
              "name": "text",
              "value": "={{ $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a62c4077-d4b4-4984-9204-134a9e4888fa",
      "name": "Set 'Text'",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -80,
        140
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Voice"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8c844924-b2ed-48b0-935c-c66a8fd0c778",
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Text"
            }
          ]
        },
        "options": {}
      },
      "id": "dfa0d92e-7b9a-4c64-bc66-f0ed13378ace",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -340,
        80
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "474863d2-4cfb-40ba-855a-5efd4d7a2be8",
      "name": "Response",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        640,
        80
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}"
      },
      "id": "3d5271d5-9ad7-4a75-8c9f-b3de5cbcb55a",
      "name": "Download File",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -140,
        -20
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "id": "a30575b9-7b22-45af-90e9-533bd321ff4b",
      "name": "Transcribe",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        -20,
        -20
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=# Overview\nYou are an AI Coordinator, designed to efficiently route user requests to specialized tools. Your role is to understand user queries and delegate them to the appropriate tool - never attempt to handle tasks directly.\n\n# Available Tools\n\n## elizaTool (Expert)\nPurpose: Interface with a specialized blockchain expert agent\nCapabilities:\n- Real-time ecosystem data and TVL monitoring\n- DeFi protocol analysis and market data\n- Technical documentation and development guidance\n- Wallet analysis and transaction insights\nUsage Format:\n- Input: Any related query\n- Action: \"Use elizaTool with message: {user's question}\"\n- Output: Expert analysis and response from the  agent\n\nExample:\nUser: \"What's happening in DeFi today?\"\nAction: Use elizaTool with message: \"What's happening in DeFi today?\"\n\n## emailTool\nPurpose: Handle all email-related operations\nCapabilities:\n- Send and draft emails\n- Manage email responses\n- Schedule email-related tasks\nUsage Format:\n- Input: Email-related request\n- Action: \"Use emailTool with: {email task details}\"\n- Output: Confirmation of email action\n\n# Operating Rules\n1. Tool Selection:\n   - Always choose the most appropriate tool for the task\n   - Use only one tool at a time unless explicitly needed\n   - If unsure, ask for clarification\n\n2. Contact Information:\n   - For any action requiring contact details (emails, calendar events), first get contact information\n   - Sequence: Look up contact \u2192 Proceed with main action\n\n3. Response Format:\n   - Keep responses concise and focused\n   - Always confirm when actions are completed\n   - If a tool fails, inform the user and suggest alternatives\n\n# Current Time\nCurrent date/time: {{ $now }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        180,
        80
      ],
      "id": "a1df8d10-d0fa-4b05-ae1e-66554b8a95b7",
      "name": "AI Coordinator"
    },
    {
      "parameters": {
        "name": "elizaAgent",
        "description": "This tool connects to a specialized blockchain expert agent that provides real-time ecosystem insights and technical guidance. The agent monitors DeFi protocols, TVL, market activities, and can assist with development queries. It has access to current blockchain data and can provide detailed analysis of transactions, protocols, and market trends.\n\nInput: Any question or request related to blockchain ecosystem\nOutput: Expert analysis and detailed response from the specialized agent\nExample: \"What's the current TVL in Global DeFi ecosystem?\"",
        "workflowId": {
          "__rl": true,
          "value": "pkNnl1sJxqMMKc2h",
          "mode": "list",
          "cachedResultName": "Expert Eliza Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2,
      "position": [
        320,
        420
      ],
      "id": "f8db9309-714d-4ace-95c9-71e0dae86289",
      "name": "Expert Agent"
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Coordinator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Coordinator",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Tavily": {
      "ai_tool": [
        [
          {
            "node": "AI Coordinator",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Coordinator",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set 'Text'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set 'Text'": {
      "main": [
        [
          {
            "node": "AI Coordinator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Transcribe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe": {
      "main": [
        [
          {
            "node": "AI Coordinator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Coordinator": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expert Agent": {
      "ai_tool": [
        [
          {
            "node": "AI Coordinator",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "088afae1-fd43-4df5-b4da-00c40375a9f6",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "29nYhxYUM0dlB4ko",
  "tags": []
}