{
  "id": "wgebr18bzsF4QNVr",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "ServiceNow L1 Support Agent",
  "tags": [],
  "nodes": [
    {
      "id": "ad145ddf-9106-441d-94cd-ed87bbc85658",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -352,
        16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "c0366cfa-74e0-405c-9941-a844262d84d0",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -240,
        272
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2b11cc62-9c8f-4248-86c3-6c8ebfe84361",
      "name": "Text Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        -80,
        48
      ],
      "parameters": {
        "options": {
          "enableAutoFixing": true,
          "systemPromptTemplate": "Please classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the json."
        },
        "inputText": "={{ $json.chatInput }}",
        "categories": {
          "categories": [
            {
              "category": "Incident",
              "description": "Incident- If something is broken or not working or it's a complaint etc. Then it is an incident "
            },
            {
              "category": "Request",
              "description": "Request- If something is a access request or provisioning ask, product etc orders then it is request"
            },
            {
              "category": "Everything Else",
              "description": "Everything which is not part of either of those categories must come here like Knowledge Search"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "4fee1f25-ad74-4cc4-81ad-ffec25bdee26",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        272
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant. Who creates requests based on the user query using the tool. Always create the request using the http tool attached to you"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "823405a4-92b9-46ac-a241-b3a428a1c940",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        352,
        496
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d0d74ce3-d5cc-47ab-85c8-d06e95d553dd",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        544,
        496
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "aa1dfb61-1da5-46f5-9357-78477ddd7fce",
      "name": "Summarization Chain",
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "position": [
        1104,
        64
      ],
      "parameters": {
        "options": {
          "summarizationMethodAndPrompts": {
            "values": {
              "prompt": "=Write a user friendly summary of the following:\n\n\nAgent Action\"{text}\" \nUser Query\"{{ $('When chat message received').item.json.chatInput }}\"\n\n\nCONCISE SUMMARY: ",
              "summarizationMethod": "stuff"
            }
          }
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f0843c75-fe30-4bed-8427-d975e5e7dd5c",
      "name": "OpenAI Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1184,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9e170bf4-ca79-466b-a57b-80bf0f56d007",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        560,
        32
      ],
      "parameters": {
        "url": "https://dev353652.service-now.com/api/sn_sc/servicecatalog/items/a4cc1293939362504311f6fa3d03d698/order_now",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"sysparm_quantity\": 1,\n  \"variables\": {\n    \"description\": \"{{ $('When chat message received').item.json.chatInput }}\"\n  }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "serviceNowBasicApi"
      },
      "credentials": {
        "serviceNowBasicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "afb9f332-0972-4854-a3fb-180992307f49",
      "name": "Create an incident",
      "type": "n8n-nodes-base.serviceNow",
      "position": [
        560,
        -144
      ],
      "parameters": {
        "resource": "incident",
        "operation": "create",
        "authentication": "basicAuth",
        "additionalFields": {},
        "short_description": "={{ $('When chat message received').item.json.chatInput }}"
      },
      "credentials": {
        "serviceNowBasicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7fa36225-2adb-4534-9652-b55afbcb14f4",
      "name": "SerpAPI",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        736,
        496
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "serpApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b7b3f641-523a-4360-9e56-1f7e4b614128",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -192
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 208,
        "content": "## Text Classifier\n\nThis will categorize all the user queries in 3 categorize\n1- Incident\n2-Request\n3- Everything Else\n"
      },
      "typeVersion": 1
    },
    {
      "id": "020ea78c-ae47-4937-9867-ceb6a9503aa5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -288
      ],
      "parameters": {
        "content": "## Create Incident\nUsing ServiceNow Connector to create an Incident"
      },
      "typeVersion": 1
    },
    {
      "id": "acdb5a12-9f4a-4dfd-8f82-b4ad8ccbe4ef",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        320
      ],
      "parameters": {
        "content": "## Lastly\nTo handle all other cases. I am using a AI Agent with Web Search API"
      },
      "typeVersion": 1
    },
    {
      "id": "a7f8c6f9-d624-46fc-8f04-f4dd7164adb7",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -48
      ],
      "parameters": {
        "height": 272,
        "content": "## Submit a General Request\nFor Demo Purpose I am only Submitting a General Request. Using Service Catalog API https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_ServiceCatalogAPI.html#title_servicecat-POST-cart-sub_order"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "78eec813-6c33-4ab8-a496-1e5d47eb4311",
  "connections": {
    "SerpAPI": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "Create an incident",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create an incident": {
      "main": [
        [
          {
            "node": "Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Summarization Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}