{
  "name": "Think Tool Demo",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -300,
        -140
      ],
      "id": "66cf8e0d-0ec1-4389-81ac-f021e94ec2cd",
      "name": "When chat message received",
      "webhookId": "88ed91a9-323a-41f3-85f7-2fc05036c16c"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -360,
        80
      ],
      "id": "554ea6e7-f340-41b9-86bb-8cb240a28023",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "MzIepidaRw9ZqcPB",
          "name": "OpenAi account Credentials"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        -220,
        80
      ],
      "id": "69c86d89-4407-47dd-8bf2-e5517229f713",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1s9oaGi7gj0Wk1NdP0ywxxSx64fab4bq0toYMpZiMT24",
          "mode": "list",
          "cachedResultName": "Lead Data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1s9oaGi7gj0Wk1NdP0ywxxSx64fab4bq0toYMpZiMT24/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "leads",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1s9oaGi7gj0Wk1NdP0ywxxSx64fab4bq0toYMpZiMT24/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "displayName": "Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "displayName": "City",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "displayName": "Country",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Search",
              "displayName": "Search",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        220,
        80
      ],
      "id": "3f388c6c-4a38-4b1d-84d9-32d8487ff8d8",
      "name": "Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ESD8JJHqd8A9NlNx",
          "name": "Google Sheets account (Kris)"
        }
      }
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "You are a customer support agent who helps customers resolve order and shipping issues.\n\nYour goal is to resolve customer issues quickly, reduce ticket volume, and improve satisfaction.\n\nBe friendly, clear, and professional. Use plain English. Keep answers short unless more detail is asked.\n\nTools:\n\nYou can use the following tools to complete your tasks:\n– Google Sheets to create and update support tickets.\n– Calculator to work out partial refund amounts based on delays.\n– Chat tools (like Telegram or Gmail) to send replies to customers.\nBe specific and accurate when using these tools, and always confirm actions before proceeding.\n\nTask for each support request:\nAsk for the order number.\nLog a new support ticket in Google Sheets.\nFind the order details.\nCheck if it’s delayed.\nIf so, calculate a 10% refund.\nReply with tracking or refund info.\n\nEdge cases\nIf the user doesn’t provide an order number, politely ask for it. If the order isn’t found, offer to escalate to a human.\n\nGuardrails\nNever offer full refunds, discounts, or replacements on your own.\nAvoid giving personal opinions or making assumptions.\nIf a request involves payment, sensitive info, or anything outside your tools, escalate to a human.\nOnly use the tools listed — don’t make up actions or access other systems.\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        -120,
        -140
      ],
      "id": "1f19cbcc-ce77-4d55-8a2a-d9b91bdfdd3c",
      "name": "Customer Support AI Agent"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        80,
        80
      ],
      "id": "c71d995f-d9c7-455c-a325-b0858b821a65",
      "name": "Calculator"
    },
    {
      "parameters": {
        "description": "Before responding to the user, review the draft reply against these rules:\n\n1. ✅ The reply must be clear, friendly, and professional — no technical jargon or overly formal language.\n2. ✅ If the output includes a refund, confirm that it's a 10% partial refund only, and based on delay logic.\n3. ✅ Check if the agent correctly asked for the order number if it wasn’t already provided.\n4. ✅ Ensure only allowed tools are referenced: Google Sheets, Calculator, chat tools (e.g., Gmail or Telegram).\n5. ✅ Make sure the agent does **not** offer full refunds, discounts, replacements, or access unauthorized systems.\n6. ✅ If the issue cannot be solved, ensure the agent offers to escalate to a human — not solve it on its own.\n7. ✅ Confirm the tone is aligned with customer support: empathetic, solution-focused, and concise.\n\nIf any rule is violated, revise the response before sending. Do **not** explain or add reasoning — just fix and return the final reply.\n"
      },
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1,
      "position": [
        -60,
        160
      ],
      "id": "9a38b99b-6ac4-4ae7-8b49-6e26499bee27",
      "name": "Think"
    }
  ],
  "pinData": {},
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Customer Support AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Customer Support AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Customer Support AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "Customer Support AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Customer Support AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Think": {
      "ai_tool": [
        [
          {
            "node": "Customer Support AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8903dc45-d2a1-4e05-b1c4-7ea4a8edcd33",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "4aabc0aa2e160dafa4f9d9bcedde563b5af29598cd16960f637ae2fb99aea720"
  },
  "id": "FShbGXTqPI9uHdQv",
  "tags": []
}