{
  "nodes": [
    {
      "id": "1500ed8c-4291-45dd-a04d-ef56f39e9ac1",
      "name": "Website Chat Messages",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -176,
        0
      ],
      "parameters": {
        "path": "demo-workflow",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "56526257-ac25-4c8f-8caa-ddff585f8f34",
      "name": "Convert Chat Text",
      "type": "n8n-nodes-base.set",
      "position": [
        16,
        0
      ],
      "parameters": {
        "assignments": [
          {
            "name": "chatInput",
            "type": "string",
            "value": "={{$json[\"body\"][\"chatinput\"]}}"
          }
        ]
      },
      "typeVersion": 3.4
    },
    {
      "id": "fa82d7db-c223-45b4-822c-756548e017d8",
      "name": "Forerunner™ AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        208,
        0
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a demo agent for Forerunner™ AI, the very latest in AI chatbots developed by Design for Online®. When you introduce yourself, make sure to say you are a demo chat agent using a custom n8n workflow."
        }
      },
      "typeVersion": 1.9
    },
    {
      "id": "837c40e5-a27a-4b5f-be5b-c60021644397",
      "name": "End Conversation?",
      "type": "n8n-nodes-base.if",
      "position": [
        592,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "[END_OF_CONVERSATION]"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "92b0b116-e4e4-4e7c-9748-052f5dd705d6",
      "name": "Yes - End",
      "type": "n8n-nodes-base.set",
      "position": [
        912,
        -96
      ],
      "parameters": {
        "assignments": [
          {
            "name": "reply",
            "type": "string",
            "value": "={{ $json.output.replace('[END_OF_CONVERSATION]', '').trim() }}"
          },
          {
            "name": "endOfConversation",
            "type": "boolean",
            "value": true
          }
        ]
      },
      "typeVersion": 3.4
    },
    {
      "id": "533a8fea-34fc-402a-a031-024073e1c62d",
      "name": "No - Continue",
      "type": "n8n-nodes-base.set",
      "position": [
        912,
        112
      ],
      "parameters": {
        "assignments": [
          {
            "name": "=reply",
            "type": "string",
            "value": "={{ $json.output }}"
          }
        ]
      },
      "typeVersion": 3.4
    },
    {
      "id": "4a247e7a-e49c-4c61-9270-b376d3e11c1c",
      "name": "Send Chat to Client",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1200,
        0
      ],
      "parameters": {},
      "typeVersion": 1.2
    }
  ],
  "connections": {
    "Website Chat Messages": {
      "main": [
        [
          {
            "node": "Convert Chat Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Chat Text": {
      "main": [
        [
          {
            "node": "Forerunner™ AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Forerunner™ AI Agent": {
      "main": [
        [
          {
            "node": "End Conversation?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "End Conversation?": {
      "main": [
        [
          {
            "node": "Yes - End",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No - Continue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Yes - End": {
      "main": [
        [
          {
            "node": "Send Chat to Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No - Continue": {
      "main": [
        [
          {
            "node": "Send Chat to Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}