{
  "name": "03 - AI Agent with Tools",
  "nodes": [
    {
      "parameters": {
        "content": "## 03 AI Agent with Tools\nAdd your OpenAI credential, then open Chat and try:\n- What is 18% of 4999?\n- Look up the GitHub user torvalds\n- What was my first question? (memory)\n\nOpen the github_user_lookup tool: $fromAI() lets the AI fill the username.",
        "height": 240,
        "width": 460
      },
      "id": "03000000-0000-4000-8000-000000000000",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-60, -300]
    },
    {
      "parameters": { "options": {} },
      "id": "03000000-0000-4000-8000-000000000001",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [0, 0],
      "webhookId": "0b2c3d4e-0303-4a2b-9c3d-7e8f9a0b1c03"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "You are a helpful QA assistant. Use the calculator for any math. Use github_user_lookup when the user asks about a GitHub user. Keep answers short."
        }
      },
      "id": "03000000-0000-4000-8000-000000000002",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [240, 0]
    },
    {
      "parameters": {
        "model": { "__rl": true, "mode": "list", "value": "gpt-4o-mini" },
        "options": {}
      },
      "id": "03000000-0000-4000-8000-000000000003",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [100, 220]
    },
    {
      "parameters": { "contextWindowLength": 10 },
      "id": "03000000-0000-4000-8000-000000000004",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [240, 220]
    },
    {
      "parameters": {},
      "id": "03000000-0000-4000-8000-000000000005",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [380, 220]
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Looks up a public GitHub user profile (name, bio, public repos, followers).",
        "url": "=https://api.github.com/users/{{ $fromAI('username', 'GitHub username to look up', 'string') }}",
        "options": {}
      },
      "id": "03000000-0000-4000-8000-000000000006",
      "name": "github_user_lookup",
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [520, 220]
    }
  ],
  "connections": {
    "When chat message received": { "main": [[{ "node": "AI Agent", "type": "main", "index": 0 }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]] },
    "Simple Memory": { "ai_memory": [[{ "node": "AI Agent", "type": "ai_memory", "index": 0 }]] },
    "Calculator": { "ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]] },
    "github_user_lookup": { "ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "active": false
}
