{
  "name": "eval_Guardrails_mode_check_text_for_violations",
  "nodes": [
    {
      "parameters": {
        "options": {
          "responseMode": "responseNodes"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        -752,
        -80
      ],
      "id": "9fd3a511-f4f4-466e-ae48-670761c06470",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.guardrailsInput }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You are an AI Flight Booking Assistant supporting users with travel booking.\n\nThe user will provide travel details such as:\n- source city\n- destination city\n- budget\n- and sometimes preferred travel time.\n\nYour task is to:\n1. Search available flights from the provided flight database.\n2. Identify the most suitable flight based on the user's budget and travel route.\n3. Internally select the best flight option including:\n   - flight name\n   - source\n   - destination\n   - ticket price\n   - departure time\n   - available seats\n4. Generate professional booking details for the selected flight.\n5. Generate a professional flight booking confirmation email.\n6. Generate a professional confirmed flight booking email.\n7. Assume the email is sent only after human approval is completed in the workflow.\n8. The email should sound like a real confirmed airline reservation email.\n\nConstraints:\n\u2022 Do NOT perform payment or final reservation.\n\u2022 Do NOT explain your reasoning.\n\u2022 Do NOT ask unnecessary follow-up questions.\n\u2022 ONLY generate the booking details and email content.\n\nGuidelines:\n\u2022 Always try to select flights within the user's budget.\n\u2022 If multiple flights match, prefer the cheapest suitable option.\n\u2022 Keep the response short, clear, and professional.\n\u2022 Mention flight details clearly.\n\u2022 Use priyangbhatt321@gmail.com as the booking email for all generated bookings.\n\u2022 Write the email in a natural and professional airline confirmation style.\n\u2022 Keep the email short, clean, and realistic.\n\u2022 Avoid robotic wording.\n\u2022 Make the email look like a real airline booking confirmation email.\n\nOutput requirements:\n\u2022 Respond ONLY with structured data that matches the expected output schema.\n\u2022 Do NOT include any extra text, commentary, or formatting."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        -240,
        -160
      ],
      "id": "219fbe14-aefc-4a13-a090-7c0207106abd",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        -352,
        16
      ],
      "id": "8e9faa0d-469e-47f9-b61e-f067dfad8ebe",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1jzANiSO_ke1o-CbofwYqd371qb3_hvdhk1wz1ZUEAes",
          "mode": "list",
          "cachedResultName": "flight",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jzANiSO_ke1o-CbofwYqd371qb3_hvdhk1wz1ZUEAes/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 1301746240,
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jzANiSO_ke1o-CbofwYqd371qb3_hvdhk1wz1ZUEAes/edit#gid=1301746240"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        -192,
        16
      ],
      "id": "d44a561b-067e-4971-8aa9-6e055682cb63",
      "name": "Get row(s) in sheet in Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"name\": \"flight_booking_email\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"booking_email\": {\n      \"type\": \"string\",\n      \"description\": \"Email address where the flight ticket confirmation should be sent\"\n    },\n    \"email_subject\": {\n      \"type\": \"string\",\n      \"description\": \"Subject line for the flight booking confirmation email\"\n    },\n    \"email_body\": {\n      \"type\": \"string\",\n      \"description\": \"Professional flight booking confirmation email body with ticket details\"\n    }\n  },\n  \"required\": [\n    \"booking_email\",\n    \"email_subject\",\n    \"email_body\"\n  ]\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -48,
        16
      ],
      "id": "885ad55b-c9b3-4b94-83a0-0c13d6d18ce8",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "sendTo": "={{ $('AI Agent').item.json.output.booking_email }}",
        "subject": "={{ $('AI Agent').item.json.output.email_subject }}",
        "emailType": "text",
        "message": "={{ $('AI Agent').item.json.output.email_body }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        496,
        -208
      ],
      "id": "231a879b-95ea-4c11-85a2-0ba7f2513377",
      "name": "Send a message",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "message": "=Type approve if you want to continue with the selected flight booking, if not, type reject\n\nSubject : \n\n\n {{ $json.output.email_subject }}\n\nBody:\n\n{{ $json.output.email_body }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chat",
      "typeVersion": 1.3,
      "position": [
        288,
        -384
      ],
      "id": "79cb26c0-9598-4183-a041-a374dd2cf2e8",
      "name": "Chat"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "68988263-4685-4cf9-867e-070c045816b0",
              "leftValue": "={{ $json.chatInput }}",
              "rightValue": "approve",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        432,
        0
      ],
      "id": "aac13007-256f-4293-ad77-49cf8393d689",
      "name": "If"
    },
    {
      "parameters": {
        "text": "={{ $json.chatInput }}{{ $json['User Input'] }}",
        "guardrails": {
          "keywords": "idiot",
          "pii": {
            "value": {
              "type": "selected",
              "entities": [
                "EMAIL_ADDRESS"
              ]
            }
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.guardrails",
      "typeVersion": 2,
      "position": [
        -448,
        -288
      ],
      "id": "9fc3712e-99b5-434c-bce7-3f27ab4c2a32",
      "name": "Guardrails1"
    },
    {
      "parameters": {
        "message": "your request was blocked by the guardrails policy because it contains restricted or unsafe content. Please verify your message and try again.",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chat",
      "typeVersion": 1.3,
      "position": [
        -176,
        -336
      ],
      "id": "a228f93b-2097-4aec-ba90-0e0ded40ab87",
      "name": "Chat1"
    },
    {
      "parameters": {
        "source": "googleSheets",
        "documentId": {
          "__rl": true,
          "value": "1zwsW4Tia7cKKotkMljNUUE0tMQBBhE7SJfhhJIawR_s",
          "mode": "list",
          "cachedResultName": "Flight_Eval_Dataset",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zwsW4Tia7cKKotkMljNUUE0tMQBBhE7SJfhhJIawR_s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 324016220,
          "mode": "list",
          "cachedResultName": "sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zwsW4Tia7cKKotkMljNUUE0tMQBBhE7SJfhhJIawR_s/edit#gid=324016220"
        }
      },
      "type": "n8n-nodes-base.evaluationTrigger",
      "typeVersion": 4.7,
      "position": [
        -784,
        -352
      ],
      "id": "7348f925-97e9-442a-b99a-f97d86ca8259",
      "name": "When fetching a dataset row",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "checkIfEvaluating"
      },
      "type": "n8n-nodes-base.evaluation",
      "typeVersion": 4.8,
      "position": [
        32,
        -304
      ],
      "id": "6a0a7c89-78f3-4f42-880f-92feeff01f45",
      "name": "Evaluation"
    },
    {
      "parameters": {
        "operation": "setMetrics",
        "expectedAnswer": "={{ $('When fetching a dataset row').item.json['User Input'] }}{{ $('When fetching a dataset row').item.json['Expected Email'] }}{{ $('When fetching a dataset row').item.json['Expected Subject'] }}{{ $('When fetching a dataset row').item.json['Expected Body'] }}",
        "actualAnswer": "={{ $('AI Agent').item.json.output.booking_email }}{{ $('AI Agent').item.json.output.email_subject }}{{ $('AI Agent').item.json.output.email_body }}",
        "options": {}
      },
      "type": "n8n-nodes-base.evaluation",
      "typeVersion": 4.8,
      "position": [
        192,
        -80
      ],
      "id": "c9769755-cc84-493d-86e3-4c1651facf02",
      "name": "Evaluation1"
    },
    {
      "parameters": {
        "operation": "setInputs",
        "inputs": {
          "values": [
            {
              "inputName": "input",
              "inputValue": "={{ $json['Expected Email'] }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.evaluation",
      "typeVersion": 4.8,
      "position": [
        -624,
        -368
      ],
      "id": "14ad2a20-aa8c-414d-9bc3-ce2ca43ea93e",
      "name": "Inputs"
    },
    {
      "parameters": {
        "source": "googleSheets",
        "documentId": {
          "__rl": true,
          "value": "1zwsW4Tia7cKKotkMljNUUE0tMQBBhE7SJfhhJIawR_s",
          "mode": "list",
          "cachedResultName": "Flight_Eval_Dataset",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zwsW4Tia7cKKotkMljNUUE0tMQBBhE7SJfhhJIawR_s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 324016220,
          "mode": "list",
          "cachedResultName": "sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zwsW4Tia7cKKotkMljNUUE0tMQBBhE7SJfhhJIawR_s/edit#gid=324016220"
        },
        "outputs": {
          "values": [
            {
              "outputName": "actual_email",
              "outputValue": "={{ $('AI Agent').item.json.output.booking_email }}"
            },
            {
              "outputName": "actual_subject",
              "outputValue": "={{ $('AI Agent').item.json.output.email_subject }}"
            },
            {
              "outputName": "actual_body",
              "outputValue": "={{ $('AI Agent').item.json.output.email_body }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.evaluation",
      "typeVersion": 4.8,
      "position": [
        208,
        -240
      ],
      "id": "213c6519-1c48-4d02-bf21-ded21e8261dd",
      "name": "Evaluation2",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Guardrails1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Evaluation1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Evaluation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Guardrails1": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chat1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When fetching a dataset row": {
      "main": [
        [
          {
            "node": "Inputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evaluation": {
      "main": [
        [
          {
            "node": "Evaluation2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inputs": {
      "main": [
        [
          {
            "node": "Guardrails1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evaluation2": {
      "main": [
        [
          {
            "node": "Evaluation1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "157d253c-46d7-406d-9819-7d95b8f78356",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "edzt8uxGKIYfwptv",
  "tags": []
}