{
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {},
        "options": {}
      },
      "id": "95aed533-1ea1-4624-be07-cf59316dfe0f",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.1,
      "position": [
        -1344,
        448
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "New Billing Query",
        "message": "=Message:  {{ $('Extract Email Content').item.json.emailContent }}",
        "toList": [
          "={{ $vars.CERTIFICATE_EMAIL_INBOX }}"
        ],
        "additionalFields": {}
      },
      "name": "Notify Billing Team",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        80,
        112
      ],
      "id": "4b4ff2e0-dc66-4a1e-a85f-97945311b579"
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "New Technical Query",
        "message": "=Message:  {{ $('Extract Email Content').item.json.emailContent }}",
        "toList": [
          "={{ $vars.CERTIFICATE_EMAIL_INBOX }}"
        ],
        "additionalFields": {}
      },
      "name": "Notify Technical Team",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        80,
        272
      ],
      "id": "58bee57d-aecb-42e7-b4dd-6b5cabdc0aef"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "8caffca9-9efd-43ee-ab52-035aca2be473",
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Support Case Open",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "6897b5ff-0fe7-42da-86f3-6f7266c622ac",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -1120,
        544
      ],
      "retryOnFail": true
    },
    {
      "parameters": {
        "select": "user",
        "user": {
          "__rl": true,
          "value": "REDACTED_SLACK_USER_ID",
          "mode": "list",
          "cachedResultName": "redacted-user"
        },
        "text": "=Warning:  {{ $json.title }}",
        "otherOptions": {}
      },
      "id": "acad3ae7-7324-4a44-9516-0d3e0689710c",
      "name": "Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        544,
        448
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "New Sales Request",
        "message": "=Message:  {{ $('Extract Email Content').item.json.emailContent }}",
        "toList": [
          "={{ $vars.CERTIFICATE_EMAIL_INBOX }}"
        ],
        "additionalFields": {}
      },
      "name": "Notify Sales Inquiry",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        80,
        432
      ],
      "id": "d0208226-a36d-4000-a63b-46630b8ea39d"
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "New Feedback Query",
        "message": "=Message:  {{ $('Extract Email Content').item.json.emailContent }}",
        "toList": [
          "={{ $vars.CERTIFICATE_EMAIL_INBOX }}"
        ],
        "additionalFields": {}
      },
      "name": "Notify Feedback",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        80,
        592
      ],
      "id": "98c9c461-72f5-49ba-8f4c-88f3d408061e"
    },
    {
      "parameters": {
        "content": "## Inbound Communication\n**Capturing Incoming Customer Interactions**",
        "height": 503.27628361858206,
        "width": 216.16136919315392
      },
      "id": "5c8eb023-09f9-48b9-a4fc-68d850baca27",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1408,
        256
      ]
    },
    {
      "parameters": {
        "content": "## Email Segmentation\n**Filtering and Categorizing Requests**",
        "height": 504.8655256723715,
        "width": 408.45965770171165,
        "color": 2
      },
      "id": "adfee23d-8989-4779-b7ee-80b9ca46af07",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1184,
        256
      ]
    },
    {
      "parameters": {
        "content": "## AI-Driven Classification\n**Determining Email Context**",
        "height": 679,
        "width": 408,
        "color": 3
      },
      "id": "a260d433-0ef8-4c88-b1f0-2a8b9ea9ba79",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -768,
        256
      ]
    },
    {
      "parameters": {
        "content": "## Operational Routing\n**Directing Emails to Relevant Teams**",
        "height": 1088,
        "width": 762,
        "color": 4
      },
      "id": "4b860979-bd8b-4872-b832-b167d945ae25",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -352,
        -144
      ]
    },
    {
      "parameters": {
        "content": "## External Notifications\n**Communicating Updates to Teams**",
        "height": 491,
        "width": 408,
        "color": 5
      },
      "id": "a0a983a9-3ab6-4211-bd98-7e4b41f11937",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        416,
        224
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "Billing",
                    "rightValue": "={{ $json.output }}",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "billing"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "19a90845-164b-4e02-b836-9e3829633c4a",
                    "leftValue": "Technical",
                    "rightValue": "={{ $json.output }}",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "technical"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "d89c5825-6084-4d89-8b82-80b33b3b300f",
                    "leftValue": "Sales inquiries",
                    "rightValue": "={{ $json.output}}",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "sales inquiries"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "9a6ddf33-b373-4355-8577-24dd44e8a2b0",
                    "leftValue": "Feedback",
                    "rightValue": "={{ $json.output }}",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "feedback"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "73d704d3-e365-4104-b208-e3171e40e25a",
                    "leftValue": "General support",
                    "rightValue": "={{ $json.output }}",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "general support"
            }
          ]
        },
        "options": {
          "fallbackOutput": 4
        }
      },
      "id": "61db34c4-14c6-4020-9d09-bdeda539ff6c",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -224,
        496
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "subject": "New General support Response",
        "message": "=Thank you very much, we will be reviewing your case and get back to you.\n\nThank you.",
        "toList": [
          "={{ $vars.CERTIFICATE_EMAIL_INBOX }}"
        ],
        "additionalFields": {}
      },
      "name": "Notify Technical General Support",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        80,
        752
      ],
      "id": "d28c70f4-bc2e-45b9-9ed8-d5103c0935cd"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b651c8e3-4540-4a9e-9af4-d370b73d7fb2",
              "name": "message",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "9cd1bca6-dff4-47f2-9b6a-31907dbce8d1",
              "name": "customer_email",
              "value": "={{ $json.from.value[0].address }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -896,
        544
      ],
      "id": "82e59c27-1fc3-4665-9aca-c4ddc29eb74f",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=Specify if that text is related to billing or technical, and as an output write only one word, it has to be either \"Billing\", \"Technical\", \"Sales inquiries\", \"Feedback\" or should fallback into \"General support\""
        }
      },
      "id": "346d0408-3de1-4b16-9453-95eb837bf650",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -672,
        544
      ]
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"output\": \"string\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -536,
        768
      ],
      "id": "0498c644-0bb6-4f78-8468-86615536f8e4",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "owner",
              "value": "owner_placeholder"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executionData",
      "typeVersion": 1,
      "position": [
        -1120,
        352
      ],
      "id": "40a95e8a-415b-4544-a84d-c16b3ceee13f",
      "name": "Execution Data"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "3caf88a1-e2c7-49ad-9fb9-7cf76c534f9c",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -664,
        768
      ]
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          },
          {
            "node": "Execution Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Billing Team": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Technical Team": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Sales Inquiry": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Feedback": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Notify Billing Team",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Technical Team",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Sales Inquiry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Feedback",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Technical General Support",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Technical General Support": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}