{
  "name": "n8n ChatGPT ChatBot",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "mode": "webhook",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "293af9b3-fd62-481b-8fc6-a3392fc57bb5",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "=You are an AI chatbot assisting users on a website. Follow these instructions carefully.\n\n###Tools\n- Call the invoice_generator tool to create an invoice. You must have the user's name and email before generating an invoice. Only call this tool if the user asks for you to send it.\n\n###Rules\n1. After generating an invoice, make sure to send the invoice back to the user. The invoice_generator tool should provide the link. Here's an example of what the invoice URL looks like: \"https://link.automatable.co/l/03oLUQ5CTF\" \n2. If this is a new conversation, start by asking for the user\u2019s name and email, then how you can help them today.\n3. Ask for these details separately (i.e., in two different questions).\nAppointment Booking\n4. If the user wants to book a call or meeting, direct them to: https://abccompany.com/booking.\n5. Only call the invoice_generator tool if the user asks to generate an invoice"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        220,
        0
      ],
      "id": "3f4e06c1-f12d-40e2-9a49-9d12f80aeefc",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        60,
        220
      ],
      "id": "2e8ed6b6-eb88-488e-a124-f0256083d8ab",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        200,
        220
      ],
      "id": "19630356-554d-4753-a66e-0c72c6cc6acd",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "name": "invoice_generator",
        "description": "Call this tool when the user wants to generate an invoice",
        "workflowId": {
          "__rl": true,
          "value": "B89SA6aiCkyS2xWL",
          "mode": "list",
          "cachedResultName": "Invoice"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "email": "={{ $fromAI(\"email\", \"This is the users email\") }}",
            "name": "={{ $fromAI(\"name\", \"This is the users name\") }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2,
      "position": [
        380,
        220
      ],
      "id": "428443c9-0433-47a6-b464-d846d82e0eae",
      "name": "Invoice Generator"
    }
  ],
  "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
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Generator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4dc2d5bc-14f2-4f7d-9c97-bf4d2381f58a",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "K5L0xDNnLceV8w7l",
  "tags": []
}