{
  "name": "HR Knowledge Assistant with Sentiment & Fake Jira",
  "nodes": [
    {
      "parameters": {
        "protocol": "IMAP",
        "action": "read",
        "downloadAttachments": false
      },
      "id": "EmailTrigger",
      "name": "Email Trigger",
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "credentials": {
        "imap": "<your credential>"
      }
    },
    {
      "parameters": {
        "path": "/data/hr_docs/*.txt",
        "options": {}
      },
      "id": "ReadHRDocs",
      "name": "Read HR Docs",
      "type": "n8n-nodes-base.readBinaryFiles",
      "typeVersion": 1,
      "position": [
        500,
        150
      ]
    },
    {
      "parameters": {
        "options": {
          "encoding": "utf8"
        }
      },
      "id": "BinaryToText",
      "name": "Binary \u2192 Text",
      "type": "n8n-nodes-base.moveBinaryData",
      "typeVersion": 1,
      "position": [
        700,
        150
      ]
    },
    {
      "parameters": {
        "mode": "mergeByIndex",
        "propertyName": "data"
      },
      "id": "MergeDocs",
      "name": "Merge Docs",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        900,
        150
      ]
    },
    {
      "parameters": {
        "model": "claude-3-opus-20240229",
        "prompt": "You are an HR assistant. Answer the employee's question strictly using the following HR policy documents:\n\n{{$json[\"data\"]}}\n\nEmployee Question: {{$node[\"Email Trigger\"].json[\"text\"]}}",
        "temperature": 0.2
      },
      "id": "ClaudeAnswer",
      "name": "Claude Answer",
      "type": "n8n-nodes-base.anthropic",
      "typeVersion": 1,
      "position": [
        1150,
        150
      ],
      "credentials": {
        "anthropicApi": "<your credential>"
      }
    },
    {
      "parameters": {
        "model": "claude-3-opus-20240229",
        "prompt": "Classify the sentiment of this employee's email as one of: angry, neutral, happy.\n\nEmail: {{$node[\"Email Trigger\"].json[\"text\"]}}",
        "temperature": 0
      },
      "id": "ClaudeSentiment",
      "name": "Claude Sentiment",
      "type": "n8n-nodes-base.anthropic",
      "typeVersion": 1,
      "position": [
        1150,
        400
      ],
      "credentials": {
        "anthropicApi": "<your credential>"
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "{{$json[\"completion\"]}}",
              "operation": "contains",
              "value2": "angry"
            }
          ]
        }
      },
      "id": "IfAngry",
      "name": "If Angry",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1400,
        400
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "jira_ticket_id",
              "value": "JIRA-{{$json[\"id\"] || $json[\"random\"] || Math.floor(Math.random()*10000)}}"
            }
          ]
        },
        "options": {}
      },
      "id": "FakeJira",
      "name": "Fake Jira Ticket",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1600,
        250
      ]
    },
    {
      "parameters": {
        "fromEmail": "hr-assistant@yourcompany.com",
        "toEmail": "{{$node[\"Email Trigger\"].json[\"from\"]}}",
        "subject": "HR Policy Answer",
        "text": "Here is the answer to your HR query:\n\n{{$node[\"Claude Answer\"].json[\"completion\"]}}\n\n{{ $json[\"jira_ticket_id\"] ? \"A Jira ticket was also created: \" + $json[\"jira_ticket_id\"] : \"\" }}"
      },
      "id": "EmailReply",
      "name": "Email Reply",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        1850,
        250
      ],
      "credentials": {
        "smtp": "<your credential>"
      }
    }
  ],
  "connections": {
    "Email Trigger": {
      "main": [
        [],
        []
      ]
    },
    "Read HR Docs": {
      "main": [
        [
          {
            "node": "Binary \u2192 Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Binary \u2192 Text": {
      "main": [
        [
          {
            "node": "Merge Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Docs": {
      "main": [
        [
          {
            "node": "Claude Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Answer": {
      "main": [
        [
          {
            "node": "Email Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sentiment": {
      "main": [
        [
          {
            "node": "If Angry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Angry": {
      "main": [
        [
          {
            "node": "Fake Jira Ticket",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Fake Jira Ticket": {
      "main": [
        [
          {
            "node": "Email Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}