{
  "id": "JQP0dkQCszkc3cZy",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Team Morale Monitor",
  "tags": [],
  "nodes": [
    {
      "id": "bb8d11dc-5c7c-4e27-8090-8670682ecf9d",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -864,
        208
      ],
      "parameters": {
        "options": {},
        "batchSize": 5
      },
      "typeVersion": 1
    },
    {
      "id": "dea3c66c-a383-4092-afb5-e8e1bbe13ffb",
      "name": "Fetch Teams Messages (Simulated)1",
      "type": "n8n-nodes-base.code",
      "position": [
        -1088,
        208
      ],
      "parameters": {
        "jsCode": "\n// Placeholder: Fetch messages from Microsoft Graph API\nconst config = $input.item.json;\nreturn [{\n  json: {\n    messages: [\n      { text: \"\u4eca\u9031\u306f\u30bf\u30b9\u30af\u591a\u304f\u3066\u75b2\u308c\u305f\u3051\u3069\u3001\u307f\u3093\u306a\u9811\u5f35\u3063\u3066\u308b\uff01\", author: \"A\u3055\u3093\", createdDateTime: new Date().toISOString() },\n      { text: \"\u9032\u6357\u826f\u3044\u611f\u3058\u3002\u3042\u3068\u5c11\u3057\u3067\u5b8c\u4e86\uff01\", author: \"B\u3055\u3093\", createdDateTime: new Date().toISOString() },\n      { text: \"\u5c11\u3057\u30e2\u30c1\u30d9\u4e0b\u304c\u3063\u3066\u308b\u304b\u3082\u2026\", author: \"C\u3055\u3093\", createdDateTime: new Date().toISOString() }\n    ]\n  }\n}];\n                "
      },
      "typeVersion": 2
    },
    {
      "id": "a03c52e8-e4dd-4b7f-b6cf-398d6352fb0e",
      "name": "Log Progress1",
      "type": "n8n-nodes-base.code",
      "position": [
        -416,
        208
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "console.log('Batch processed'); return item;"
      },
      "typeVersion": 2
    },
    {
      "id": "8dec94bd-20e3-44b1-aacc-e7e2cd5da5cd",
      "name": "Weekly Morale Check Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1536,
        208
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3d6d4f1a-51d2-4bdb-b12f-d14515a86780",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1312,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "teamId",
              "type": "string",
              "value": "<YOUR_TEAM_ID>"
            },
            {
              "id": "id-2",
              "name": "channelId",
              "type": "string",
              "value": "<YOUR_CHANNEL_ID>"
            },
            {
              "id": "id-3",
              "name": "managerUserId",
              "type": "string",
              "value": "<MANAGER_USER_ID>"
            },
            {
              "id": "id-4",
              "name": "daysToAnalyze",
              "type": "number",
              "value": 7
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a4d77258-1178-4365-ad86-70448907299e",
      "name": "Aggregate Sentiment Scores",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -192,
        208
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "163118d1-9387-4678-a2d3-662d3ec34688",
      "name": "Calculate Weekly Statistics",
      "type": "n8n-nodes-base.code",
      "position": [
        48,
        208
      ],
      "parameters": {
        "jsCode": "\nconst items = $input.all();\nconst avgSentiment = (items.reduce((a,b)=>a+b.json.sentiment,0)/items.length).toFixed(2);\nconst avgStress = (items.reduce((a,b)=>a+b.json.stress,0)/items.length).toFixed(2);\nreturn [{ json: { avgSentiment, avgStress, messageCount: items.length } }];\n                "
      },
      "typeVersion": 2
    },
    {
      "id": "e061e16e-70b9-4852-86b4-e4080b3d16da",
      "name": "Generate Morale Report (OpenAI)1",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        272,
        208
      ],
      "parameters": {
        "text": "=\u3042\u306a\u305f\u306f\u3001\u308f\u305a\u304b\u306a\u60c5\u5831\u304b\u3089\u3067\u3082\u6df1\u3044\u6d1e\u5bdf\u3092\u5f15\u304d\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3001\u8d85\u4e00\u6d41\u306e\u7d44\u7e54\u884c\u52d5\u5206\u6790\u30b3\u30f3\u30b5\u30eb\u30bf\u30f3\u30c8\u3067\u3059\u3002\n\u3042\u306a\u305f\u306e\u4ed5\u4e8b\u306f\u3001\u4ee5\u4e0b\u306e\u500b\u3005\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u5206\u6790\u7d50\u679c\u3060\u3051\u3092\u983c\u308a\u306b\u3001\u30c1\u30fc\u30e0\u3067\u89b3\u6e2c\u3055\u308c\u305f\u4e8b\u5b9f\u3068\u3001\u305d\u3053\u304b\u3089\u5c0e\u304d\u51fa\u3055\u308c\u308b\u6f5c\u5728\u7684\u306a\u5146\u5019\u3092\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u306b\u5831\u544a\u3059\u308b\u3053\u3068\u3067\u3059\u3002\n\n**## \u5206\u6790\u30ec\u30dd\u30fc\u30c8**\n\n### **1. \u89b3\u6e2c\u3055\u308c\u305f\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3**\n\u307e\u305a\u3001\u5206\u6790\u5bfe\u8c61\u3068\u306a\u3063\u305f\u500b\u3005\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u5185\u5bb9\u3092\u5f15\u7528\u307e\u305f\u306f\u8981\u7d04\u3057\u3001\u5ba2\u89b3\u7684\u306a\u4e8b\u5b9f\u3068\u3057\u3066\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n### **2. \u8aad\u307f\u53d6\u308c\u308b\u5146\u5019\uff08\u30a4\u30f3\u30b5\u30a4\u30c8\uff09**\n\u6b21\u306b\u3001\u4e0a\u8a18\u306e\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u8aad\u307f\u53d6\u308c\u308b\u30c1\u30fc\u30e0\u3084\u500b\u4eba\u306e\u5fc3\u7406\u72b6\u614b\u3001\u95a2\u4fc2\u6027\u3001\u696d\u52d9\u3078\u306e\u59ff\u52e2\u306b\u3064\u3044\u3066\u3001\u3042\u306a\u305f\u306e\u5c02\u9580\u7684\u306a\u77e5\u898b\u3092\u57fa\u306b\u3001\u5177\u4f53\u7684\u304b\u3064\u6df1\u304f\u8003\u5bdf\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n- \u30dd\u30b8\u30c6\u30a3\u30d6\u306a\u5146\u5019\u306f\u4f55\u304b\uff1f\n- \u6ce8\u610f\u3059\u3079\u304d\u6f5c\u5728\u7684\u306a\u30ea\u30b9\u30af\u3084\u61f8\u5ff5\u4e8b\u9805\u306f\u4f55\u304b\uff1f\n- \u3053\u306e\u4e00\u884c\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u88cf\u306b\u306f\u3001\u3069\u306e\u3088\u3046\u306a\u80cc\u666f\u3084\u6587\u8108\u304c\u96a0\u3055\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u304b\uff1f\n\n**\u3010\u91cd\u8981\u3011**\n- \u5e73\u5747\u5024\u3084\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u300c\u6570\u300d\u306b\u3064\u3044\u3066\u306f\u4e00\u5207\u8a00\u53ca\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002\n- \u3042\u306a\u305f\u306e\u5206\u6790\u306f\u3001\u63d0\u4f9b\u3055\u308c\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u300c\u5185\u5bb9\uff08\u30c6\u30ad\u30b9\u30c8\uff09\u300d\u305d\u306e\u3082\u306e\u306b100%\u57fa\u3065\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n- \u300c\u30c7\u30fc\u30bf\u304c\u5c11\u306a\u3044\u300d\u3068\u3044\u3046\u8a00\u3044\u8a33\u306f\u7d76\u5bfe\u306b\u305b\u305a\u3001\u30d7\u30ed\u3068\u3057\u3066\u76ee\u306e\u524d\u306e\u60c5\u5831\u304b\u3089\u6700\u5927\u9650\u306e\u4fa1\u5024\u3092\u5f15\u304d\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n---\n**\u25bc\u5206\u6790\u5bfe\u8c61\u30c7\u30fc\u30bf**\n{{ JSON.stringify($('Aggregate Sentiment Scores').all()) }}\n---\n\n\u4e0a\u8a18\u306e\u30eb\u30fc\u30eb\u306b\u5f93\u3044\u3001\u30b3\u30f3\u30b5\u30eb\u30bf\u30f3\u30c8\u3068\u3057\u3066\u4fa1\u5024\u306e\u3042\u308b\u30ec\u30dd\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "document"
      },
      "typeVersion": 1
    },
    {
      "id": "bc331851-dd10-4c94-affc-ce0bb5a8cc58",
      "name": "Sentiment Analysis (OpenAI)1",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -640,
        208
      ],
      "parameters": {
        "text": "\u3042\u306a\u305f\u306f\u5fc3\u7406\u8a00\u8a9e\u5206\u6790AI\u3067\u3059\u3002\u4ee5\u4e0b\u306eTeams\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u611f\u60c5\u30c8\u30fc\u30f3\u3092\u5206\u6790\u3057\u3001\u69cb\u9020\u5316JSON\u3067\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u30e1\u30c3\u30bb\u30fc\u30b8: {{ $json.text }}\n\u6295\u7a3f\u8005: {{ $json.author }}\n\u6642\u9593\u5e2f: {{ $json.timeOfDay }}\n\u66dc\u65e5: {{ $json.dayOfWeek }}\n\n\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044:\n{\n  \"sentiment\": <1-5\u306e\u6570\u5024\u30021=\u975e\u5e38\u306b\u30cd\u30ac\u30c6\u30a3\u30d6\u30013=\u4e2d\u7acb\u30015=\u975e\u5e38\u306b\u30dd\u30b8\u30c6\u30a3\u30d6>,\n  \"emotion\": \"<\u4e3b\u306a\u611f\u60c5: \u559c\u3073/\u4e0d\u5b89/\u6012\u308a/\u75b2\u52b4/\u4e2d\u7acb\u306a\u3069>\",\n  \"stress\": <\u30b9\u30c8\u30ec\u30b9\u6307\u6a19: 0-10>,\n  \"engagement\": <\u30a8\u30f3\u30b2\u30fc\u30b8\u30e1\u30f3\u30c8: 0-10>,\n  \"key_phrases\": [\"<\u91cd\u8981\u306a\u30d5\u30ec\u30fc\u30ba1>\", \"<\u91cd\u8981\u306a\u30d5\u30ec\u30fc\u30ba2>\"],\n  \"concerns\": \"<\u61f8\u5ff5\u4e8b\u9805\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u7a7a\u6587\u5b57>\",\n  \"message\": \"{{ $json.text }}\"\n}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "document"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a4807793-b036-469d-a4c2-f873e0b84f72",
      "name": "Send a message1",
      "type": "n8n-nodes-base.slack",
      "position": [
        496,
        208
      ],
      "parameters": {
        "text": "={{ $json.content.parts[0].text }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09LUABPRGT",
          "cachedResultName": "\u30bd\u30fc\u30b7\u30e3\u30eb"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "7aa489e4-f487-4334-bd6c-4e54961b2995",
      "name": "Template Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2160,
        -48
      ],
      "parameters": {
        "width": 528,
        "height": 752,
        "content": "## AI Team Morale Monitor\n\n### Who\u2019s it for\nFor team leads, HR, and managers who want to monitor the emotional tone and morale of their teams based on message sentiment.\n\n### How it works\n1. **Trigger:** Runs every Monday at 9 AM.\n2. **Config:** Defines your Teams and Slack channels.\n3. **Fetch:** Gathers messages for the week.\n4. **AI Analysis:** Evaluates tone and stress levels.\n5. **Aggregate:** Computes team sentiment averages.\n6. **Report:** Creates a readable morale summary.\n7. **Slack Post:** Sends report to your workspace.\n\n### How to set up\n1. Connect Microsoft Teams and Slack credentials.\n2. Enter your Team and Channel IDs in the **Workflow Configuration** node.\n3. Adjust the schedule if desired.\n\n### Requirements\n- Microsoft Teams and Slack access.\n- Gemini (or OpenAI) API credentials set in AI nodes.\n\n### How to customize\n- Modify the AI prompts for different insight depth.\n- Replace Gemini with other LLMs if preferred.\n- Change posting platform or format.\n\n**Note:** This workflow uses *only* linguistic data \u2014 no personal identifiers or private metadata."
      },
      "typeVersion": 1
    },
    {
      "id": "aa1e99df-6667-42b0-8e5f-a16a95ebb704",
      "name": "Trigger Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        16
      ],
      "parameters": {
        "height": 352,
        "content": "### Weekly Trigger\nActivates automatically every Monday at 9:00 AM.\nYou can change this schedule in the node settings."
      },
      "typeVersion": 1
    },
    {
      "id": "0a1e5f36-4395-48d5-ac3a-e1434e7b4f54",
      "name": "Configuration Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        16
      ],
      "parameters": {
        "width": 208,
        "height": 352,
        "content": "### Workflow Configuration\nDefines IDs and settings such as:\n- Team ID\n- Channel ID\n- Manager User ID\n- Analysis Period (days)"
      },
      "typeVersion": 1
    },
    {
      "id": "9e301552-4f9f-4326-bb03-94b5ffbd6512",
      "name": "Fetch Messages Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1168,
        16
      ],
      "parameters": {
        "width": 464,
        "height": 352,
        "content": "### Fetch Messages\nCollects recent Microsoft Teams messages.\nReplace this with a real API node for live data."
      },
      "typeVersion": 1
    },
    {
      "id": "4346e576-a225-434e-a1fc-20c47c94fa25",
      "name": "AI Analysis Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        16
      ],
      "parameters": {
        "width": 464,
        "height": 352,
        "content": "### Sentiment Analysis\nUses Gemini or OpenAI to assess sentiment, stress, and engagement per message."
      },
      "typeVersion": 1
    },
    {
      "id": "0b81f776-097d-472b-9bf5-2ea5bc84b5d9",
      "name": "Aggregate Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        16
      ],
      "parameters": {
        "width": 448,
        "height": 352,
        "content": "### Aggregate Statistics\nCalculates weekly averages of sentiment and stress indicators."
      },
      "typeVersion": 1
    },
    {
      "id": "fc2bd727-c235-4843-88b7-7eb17179aa4e",
      "name": "Report Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        16
      ],
      "parameters": {
        "height": 352,
        "content": "### Generate Report\nSummarizes emotional insights into a readable report for managers."
      },
      "typeVersion": 1
    },
    {
      "id": "21427b2f-e985-4977-8422-642a4902a2a0",
      "name": "Slack Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        16
      ],
      "parameters": {
        "width": 208,
        "height": 352,
        "content": "### Post to Slack\nPublishes the morale report to Slack or Teams for visibility."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d5d88f18-04b2-48a3-be88-4158141b1ea5",
  "connections": {
    "Log Progress1": {
      "main": [
        [
          {
            "node": "Aggregate Sentiment Scores",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "Sentiment Analysis (OpenAI)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Fetch Teams Messages (Simulated)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Sentiment Scores": {
      "main": [
        [
          {
            "node": "Calculate Weekly Statistics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Weekly Statistics": {
      "main": [
        [
          {
            "node": "Generate Morale Report (OpenAI)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Morale Check Trigger": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sentiment Analysis (OpenAI)1": {
      "main": [
        [
          {
            "node": "Log Progress1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Morale Report (OpenAI)1": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Teams Messages (Simulated)1": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}