{
  "name": "Ask a human for help when the AI doesn't know the answer",
  "nodes": [
    {
      "id": "e12611f4-37d2-48f9-8a60-ddcf4ff34cfc",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        380
      ],
      "parameters": {
        "width": 1118.3459011229047,
        "height": 775.3931210698682,
        "content": "### Sub-workflow: Custom tool\nThe agent above can call this workflow. It checks if the user has supplied an email address. If they haven't it prompts them to provide one. If they have, it messages a c"
      }
    },
    {
      "id": "72dbee3e-fe3b-4354-9b02-2fe52af23035",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -180
      ],
      "parameters": {
        "width": 927.5,
        "height": 486.5625,
        "content": "### Main workflow: AI agent using custom tool"
      }
    },
    {
      "id": "a1c9660d-84b1-418a-bbb3-88d79cdd79d3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        60
      ],
      "parameters": {
        "width": 197.45572294791873,
        "height": 179.21380662202682,
        "content": "**This tool calls the sub-workflow below**"
      }
    },
    {
      "id": "b4ffb76d-c44f-46d6-b2d9-4e5d551adee1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        40
      ],
      "parameters": {
        "width": 150,
        "height": 213.44323866265472,
        "content": "**Set your credentials**"
      }
    },
    {
      "id": "8a9187f1-3cf9-479f-aa7f-5581880394d0",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        540
      ],
      "parameters": {
        "width": 178.0499248677781,
        "height": 250.57252651663197,
        "content": "**Set your credentials and Slack details**"
      }
    },
    {
      "id": "3f72d117-e07a-4af4-aa1b-92ce04bf0b3c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "width": 185.9375,
        "height": 214.8397420554627,
        "content": "## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Hi! Please respond to this as if you don't know the answer to my query._"
      }
    },
    {
      "id": "b85eff07-ee3c-4aeb-871e-b25a131a7afb",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        900
      ],
      "parameters": {
        "width": null,
        "height": 145,
        "content": "## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)"
      }
    },
    {
      "id": "feb1e50d-5044-4ea6-8719-72e176581e27",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -400,
        -120
      ]
    },
    {
      "id": "6af81471-7cd4-4517-9677-b634b59620b4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -240,
        120
      ]
    },
    {
      "id": "37604c8d-5c70-4a81-a1d0-eafe42ce612d",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -60,
        120
      ]
    },
    {
      "id": "fd404bb5-0703-4d08-8b9b-4a8b01fd2bff",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -380,
        740
      ]
    },
    {
      "id": "a807ca29-65bf-4d97-b89f-5ce16cd05347",
      "name": "Check if user has provided email",
      "type": "n8n-nodes-base.if",
      "position": [
        -200,
        740
      ]
    },
    {
      "id": "b9c552ce-4c58-48dd-b168-5e277de89954",
      "name": "Message Slack for help",
      "type": "n8n-nodes-base.slack",
      "position": [
        80,
        620
      ]
    },
    {
      "id": "644a05fc-ac7e-4ea9-ab03-3b6fbf7a3654",
      "name": "Confirm that we've messaged a human",
      "type": "n8n-nodes-base.code",
      "position": [
        300,
        620
      ]
    },
    {
      "id": "38e81aa5-30b3-48f9-88e8-1039f607f3e7",
      "name": "Prompt the user to provide an email",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        860
      ]
    },
    {
      "id": "61ddb25a-f7f2-4691-94d5-3f32c183ec46",
      "name": "Not sure?",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        140,
        120
      ]
    },
    {
      "id": "395349d1-1715-4550-a0c8-1388d17b4386",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -180,
        -120
      ]
    }
  ],
  "connections": {
    "Not sure?": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "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
          }
        ]
      ]
    },
    "Message Slack for help": {
      "main": [
        [
          {
            "node": "Confirm that we've messaged a human",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if user has provided email": {
      "main": [
        [
          {
            "node": "Message Slack for help",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prompt the user to provide an email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Check if user has provided email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}