{
  "name": "HYPEAKZ \u2014 Customer Feedback Sentiment Analyzer (100% Local)",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute",
              "minute": 30
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "value": "Feedback"
        }
      },
      "id": "node-sheets-trigger",
      "name": "New Feedback (Google Sheets)",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "model": "llama3.2",
        "baseUrl": "http://ollama:11434"
      },
      "id": "node-ollama",
      "name": "Ollama Local LLM",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "typeVersion": 1,
      "position": [
        550,
        500
      ]
    },
    {
      "parameters": {
        "categories": {
          "categories": [
            {
              "category": "POSITIVE",
              "description": "Happy customer, praise, satisfaction, recommendation"
            },
            {
              "category": "NEGATIVE",
              "description": "Complaint, frustration, problem, churn risk"
            },
            {
              "category": "NEUTRAL",
              "description": "Question, suggestion, informational"
            },
            {
              "category": "URGENT",
              "description": "Immediate action needed, service down, billing error"
            }
          ]
        },
        "inputText": "={{ $json.feedback_text }}",
        "options": {
          "systemMessage": "You are a customer feedback analyst. Classify the sentiment accurately. If in doubt between negative and urgent, choose urgent."
        }
      },
      "id": "node-sentiment",
      "name": "Analyze Sentiment (AI)",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1,
      "position": [
        550,
        300
      ]
    },
    {
      "parameters": {
        "prompt": "Extract key information from this customer feedback:\n\nFeedback: {{ $('New Feedback (Google Sheets)').item.json.feedback_text }}\nSentiment: {{ $json.category }}\n\nReturn JSON with:\n- main_issue: one sentence summary\n- suggested_action: what the team should do\n- priority: high/medium/low\n- department: support/product/billing/sales"
      },
      "id": "node-extract-info",
      "name": "Extract Action Items (AI)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.4,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Analyze Sentiment (AI)').item.json.category }}",
              "operation": "equals",
              "value2": "URGENT"
            }
          ]
        }
      },
      "id": "node-if-urgent",
      "name": "Urgent?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1100,
        200
      ]
    },
    {
      "parameters": {
        "channel": "#alerts",
        "text": ":rotating_light: URGENT FEEDBACK\n*From:* {{ $('New Feedback (Google Sheets)').item.json.customer_name }}\n*Issue:* {{ $json.text }}\n*Sentiment:* {{ $('Analyze Sentiment (AI)').item.json.category }}"
      },
      "id": "node-slack",
      "name": "Alert Team (Slack)",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1350,
        100
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "value": "Sentiment Log"
        }
      },
      "id": "node-log",
      "name": "Log Results",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1350,
        400
      ]
    }
  ],
  "connections": {
    "New Feedback (Google Sheets)": {
      "main": [
        [
          {
            "node": "Analyze Sentiment (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Local LLM": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Sentiment (AI)",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Extract Action Items (AI)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Sentiment (AI)": {
      "main": [
        [
          {
            "node": "Extract Action Items (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Action Items (AI)": {
      "main": [
        [
          {
            "node": "Urgent?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Urgent?": {
      "main": [
        [
          {
            "node": "Alert Team (Slack)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "HYPEAKZ.IO"
    },
    {
      "name": "Self-Hosted AI"
    },
    {
      "name": "Ollama"
    },
    {
      "name": "Sentiment Analysis"
    }
  ]
}