{
  "id": "h2qfaxcvWVeS6e6r",
  "name": "Multi-agent daily metrics analysis with slack and Gmail reporting",
  "tags": [],
  "nodes": [
    {
      "id": "cece460c-c479-4d8b-90b7-84e8663ef37c",
      "name": "Daily Metrics Collection",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        576,
        464
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "4d7d965e-e1be-44fd-8a8f-f7bc3d747a99",
      "name": "Planning Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1056,
        400
      ],
      "parameters": {
        "text": "={{ $json.metricsData || 'Analyze current engineering metrics: velocity trends, backlog status, and incident patterns. Coordinate with sub-agents to generate insights, identify alerts, and prepare leadership reporting.' }}",
        "options": {
          "systemMessage": "You are the Planning Agent, the orchestrator of engineering metrics analysis. Your role is to coordinate specialized sub-agents (Metrics, Insights, Alerts, Reporting) to analyze velocity, backlog, and incident data, then synthesize their findings into actionable intelligence for leadership. Delegate analysis tasks to appropriate sub-agents, then compile their outputs into a comprehensive report."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "8bbf9331-92d3-4d4d-b2a2-4be235c982c5",
      "name": "Planning Agent Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        864
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {
          "temperature": 0.3
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8ee9f865-f4a2-4b0b-99d9-76fd0ccd0a21",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1792,
        864
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"metricsAnalysis\": {\n\t\t\t\"type\": \"object\"\n\t\t},\n\t\t\"insights\": {\n\t\t\t\"type\": \"array\"\n\t\t},\n\t\t\"alerts\": {\n\t\t\t\"type\": \"array\"\n\t\t},\n\t\t\"executiveSummary\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"recommendations\": {\n\t\t\t\"type\": \"array\"\n\t\t},\n\t\t\"timestamp\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "99e5712c-9897-486b-bc20-9d514a97fcac",
      "name": "Metrics Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        576,
        864
      ],
      "parameters": {
        "text": "={{ $fromAI('metricsTask', 'The specific metrics analysis task to perform') }}",
        "options": {
          "systemMessage": "You are the Metrics Agent, specialized in analyzing engineering performance data. Your expertise includes: 1) Velocity analysis - sprint completion rates, story point trends, throughput metrics. 2) Backlog analysis - growth rates, age distribution, priority breakdown. 3) Incident analysis - frequency patterns, severity distribution, MTTR calculations. Use the calculator for computations and access Google Sheets for historical data. Provide quantitative analysis with specific numbers and trends."
        },
        "toolDescription": "Analyzes structured velocity, backlog, and incident signals. Calculates trends, identifies anomalies, and computes key metrics like sprint velocity, backlog growth rate, incident frequency, and MTTR."
      },
      "typeVersion": 3
    },
    {
      "id": "cc71a816-e69e-4348-8f78-1f05189de206",
      "name": "Metrics Agent Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        416,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {
          "temperature": 0.2
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "43f963e6-568f-416b-8e83-2d34dfa16f35",
      "name": "Calculator Tool",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        592,
        1072
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c7da43c8-61fa-4b5b-88fc-cfd03c781ce5",
      "name": "Metrics Data Sheet Tool",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        736,
        1072
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "descriptionType": "manual",
        "toolDescription": "Reads velocity, backlog, and incident metrics from Google Sheets"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e424dedb-735d-41cf-808c-63e7e357f38c",
      "name": "Insights Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        864,
        864
      ],
      "parameters": {
        "text": "={{ $fromAI('insightsTask', 'The metrics data to analyze for insights') }}",
        "options": {
          "systemMessage": "You are the Insights Agent, specialized in deriving actionable intelligence from engineering metrics. Your role is to: 1) Identify meaningful patterns and trends in the data. 2) Correlate metrics across velocity, backlog, and incidents to find root causes. 3) Generate strategic recommendations for process improvements. 4) Highlight opportunities for optimization. Use the trend analysis code tool for statistical analysis. Focus on WHY metrics are changing and WHAT actions should be taken."
        },
        "toolDescription": "Generates actionable insights from metrics analysis. Identifies patterns, correlations, root causes, and strategic recommendations based on velocity, backlog, and incident data."
      },
      "typeVersion": 3
    },
    {
      "id": "da814f58-8b45-4540-b2b5-1206b61c915e",
      "name": "Insights Agent Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        880,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {
          "temperature": 0.5
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8f77899b-4aea-40c1-a961-4924d7abdfa0",
      "name": "Trend Analysis Code Tool",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        1024,
        1072
      ],
      "parameters": {
        "description": "Performs statistical trend analysis, correlation calculations, and pattern detection on metrics data"
      },
      "typeVersion": 1.3
    },
    {
      "id": "be8bef7a-b218-4c25-8ee5-84ef3275eff8",
      "name": "Alerts Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        1216,
        864
      ],
      "parameters": {
        "text": "={{ $fromAI('alertsTask', 'The metrics data to scan for critical alerts') }}",
        "options": {
          "systemMessage": "You are the Alerts Agent, specialized in identifying critical issues that require immediate attention. Your responsibilities: 1) Detect threshold violations (e.g., velocity drops >20%, backlog growth >30%, incident spikes). 2) Identify anomalies and outliers in metrics patterns. 3) Assess severity and urgency of issues. 4) Determine appropriate escalation channels. 5) Send alerts via Slack when critical conditions are detected. Focus on actionable alerts that require immediate response, not routine reporting."
        },
        "toolDescription": "Identifies critical issues requiring immediate attention. Detects threshold violations, anomalies, and urgent situations in velocity, backlog, or incident metrics that need escalation."
      },
      "typeVersion": 3
    },
    {
      "id": "35da7ca3-0f78-4c30-908f-faf2edc203ad",
      "name": "Alerts Agent Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1264,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {
          "temperature": 0.1
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "36f394b8-de68-4582-a348-16a7c918b9c7",
      "name": "Slack Alert Tool",
      "type": "n8n-nodes-base.slackTool",
      "position": [
        1408,
        1072
      ],
      "parameters": {
        "text": "={{ $fromAI('alertMessage', 'The alert message to send to Slack') }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $fromAI('slackChannel', 'The Slack channel ID to send the alert to', 'string', '#engineering-alerts') }}"
        },
        "otherOptions": {},
        "authentication": "oAuth2",
        "descriptionType": "manual",
        "toolDescription": "Sends critical alerts to Slack channels for immediate team visibility"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "7bf27748-a358-49dc-b816-e16539c46097",
      "name": "Reporting Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        1504,
        864
      ],
      "parameters": {
        "text": "={{ $fromAI('reportingTask', 'The analysis results to compile into a leadership report') }}",
        "options": {
          "systemMessage": "You are the Reporting Agent, specialized in creating executive-level reports for leadership. Your role is to: 1) Synthesize complex metrics data into clear executive summaries. 2) Highlight key findings, trends, and recommendations. 3) Structure reports for different audiences (executives, managers, teams). 4) Format reports professionally with clear sections: Executive Summary, Key Metrics, Insights, Alerts, Recommendations. 5) Send reports via Gmail to leadership stakeholders. Focus on clarity, actionability, and strategic context."
        },
        "toolDescription": "Creates executive summaries and leadership reports. Synthesizes metrics, insights, and alerts into clear, actionable reports for stakeholders and executives."
      },
      "typeVersion": 3
    },
    {
      "id": "7d16fa97-8d16-4418-9cbe-230211d6eb73",
      "name": "Reporting Agent Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1568,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {
          "temperature": 0.4
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "92d316f8-878e-4259-8081-5a6437a9a0bb",
      "name": "Gmail Report Tool",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        1744,
        1088
      ],
      "parameters": {
        "sendTo": "={{ $fromAI('recipients', 'Email addresses of leadership recipients', 'string', '<__PLACEHOLDER_VALUE__leadership_email__>') }}",
        "message": "={{ $fromAI('reportContent', 'The formatted report content to send') }}",
        "options": {},
        "subject": "={{ $fromAI('emailSubject', 'The email subject line', 'string', 'Engineering Metrics Report') }}",
        "descriptionType": "manual",
        "toolDescription": "Sends leadership reports via Gmail to executives and stakeholders"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c3836691-97f2-4db3-a29c-f8fce17c8204",
      "name": "Format Final Output",
      "type": "n8n-nodes-base.set",
      "position": [
        1984,
        592
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "id-2",
              "name": "metricsAnalysis",
              "type": "object",
              "value": "={{ $json.metricsAnalysis }}"
            },
            {
              "id": "id-3",
              "name": "insights",
              "type": "array",
              "value": "={{ $json.insights }}"
            },
            {
              "id": "id-4",
              "name": "alerts",
              "type": "array",
              "value": "={{ $json.alerts }}"
            },
            {
              "id": "id-5",
              "name": "executiveSummary",
              "type": "string",
              "value": "={{ $json.executiveSummary }}"
            },
            {
              "id": "id-6",
              "name": "recommendations",
              "type": "array",
              "value": "={{ $json.recommendations }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "0f272cfd-2b89-474a-8dab-673eb871ba41",
      "name": "Store Analysis Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2224,
        592
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "124d47c0-7d25-4188-931f-9667d09adfaf",
      "name": "Post Summary to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        2224,
        784
      ],
      "parameters": {
        "text": "=\ud83d\udcca *Engineering Metrics Analysis Complete*\n\n*Executive Summary:*\n{{ $('Planning Agent').item.json.output.executiveSummary }}\n\n*Key Insights:* {{ $('Planning Agent').item.json.output.insights.length }} identified\n*Alerts:* {{ $('Planning Agent').item.json.output.alerts.length }} critical issues\n*Recommendations:* {{ $('Planning Agent').item.json.output.recommendations.length }} action items\n\nFull report sent to leadership via email.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#engineering-metrics"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "f9ca416b-4d57-420d-8835-aee9666cfe87",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 512,
        "height": 352,
        "content": "## Prerequisites\n- Google Sheets OAuth2 credentials\n- Slack Bot Token with post permissions\n- Gmail OAuth2 credentials\n## Use Cases\n- Daily sales or operational KPI monitoring for business teams\n## Customization\n- Swap OpenAI models per agent for cost/performance tuning\n## Benefits\n- Eliminates manual daily reporting effort\n- Real-time alerts reduce response time to anomalies"
      },
      "typeVersion": 1
    },
    {
      "id": "d3467d5c-8895-461c-8ab2-3428aa63f1f7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -32
      ],
      "parameters": {
        "width": 352,
        "height": 304,
        "content": "## Setup Steps\n1. Connect a Schedule Trigger node for daily execution frequency.\n2. Add OpenAI credentials to the Planning Agent Model and all sub-agent models.\n3. Configure Google Sheets node with OAuth2;  \n4. Set up Slack credentials; assign correct channel in Slack Alert Tool and Post Summary nodes.\n5. Add Gmail credentials to the Gmail Report Tool node; set recipient address."
      },
      "typeVersion": 1
    },
    {
      "id": "c1cb9937-07d7-409b-b4ee-507c2b2fdc0f",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -48
      ],
      "parameters": {
        "width": 544,
        "height": 336,
        "content": "\n## How It Works\nThis workflow automates daily business metrics collection, analysis, and reporting using a multi-agent AI architecture in n8n. Designed for operations teams, analysts, and business managers, it eliminates manual data review by orchestrating four specialised sub-agents under a central Planning Agent. Each agent handles a distinct function: metrics computation, trend analysis, alert detection, and report generation. The Planning Agent coordinates task delegation via chat memory, ensuring contextual continuity across agent calls. Raw metrics are read from Google Sheets, processed through a Calculator and Trend Analysis Code Tool, and anomalies trigger Slack alerts in real time. A Structured Output Parser formats the consolidated findings, which are appended back to Google Sheets and simultaneously dispatched via Gmail and Slack. This end-to-end pipeline replaces fragmented manual workflows, delivering consistent, timely insights with full audit trails."
      },
      "typeVersion": 1
    },
    {
      "id": "4e42ae91-fb12-4b67-9188-40b9c6f31778",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        624
      ],
      "parameters": {
        "color": 7,
        "width": 1008,
        "height": 592,
        "content": "## Metrics & Insights Processing\n**What:** Metrics Agent computes KPIs; Insights Agent runs trend analysis.\n**Why:** Separates computation from analysis for modular, accurate processing."
      },
      "typeVersion": 1
    },
    {
      "id": "6457aff7-2dc8-434e-aedf-1fa57918b5b7",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        720
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 512,
        "content": "## Alerts & Reporting\n**What:** Alerts Agent triggers Slack notifications; Reporting Agent drafts summaries.\n**Why:** Delivers real-time anomaly alerts and structured reports without manual intervention."
      },
      "typeVersion": 1
    },
    {
      "id": "aa4ac3f5-9c14-4adc-850f-eee0093b9227",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 1760,
        "height": 288,
        "content": "## Planning Agent Orchestration\n**What:** Central AI agent delegates tasks to four sub-agents.\n**Why:** Coordinates specialised agents efficiently using shared memory and context."
      },
      "typeVersion": 1
    },
    {
      "id": "a0d84481-f8d0-432d-923b-e7bda3838cbf",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        432
      ],
      "parameters": {
        "color": 7,
        "width": 486,
        "height": 640,
        "content": "## Output Storage & Distribution\n**What:** Results appended to Google Sheets; summary posted to Slack and Gmail.\n**Why:** Maintains a persistent record while notifying stakeholders instantly."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "e091015c-58d7-4959-bee1-30f1b81e47d3",
  "connections": {
    "Planning Agent": {
      "main": [
        [
          {
            "node": "Format Final Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculator Tool": {
      "ai_tool": [
        [
          {
            "node": "Metrics Agent Tool",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Slack Alert Tool": {
      "ai_tool": [
        [
          {
            "node": "Alerts Agent Tool",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Alerts Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Planning Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Report Tool": {
      "ai_tool": [
        [
          {
            "node": "Reporting Agent Tool",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Alerts Agent Model": {
      "ai_languageModel": [
        [
          {
            "node": "Alerts Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Metrics Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Planning Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Format Final Output": {
      "main": [
        [
          {
            "node": "Store Analysis Results",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post Summary to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insights Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Planning Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Metrics Agent Model": {
      "ai_languageModel": [
        [
          {
            "node": "Metrics Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Insights Agent Model": {
      "ai_languageModel": [
        [
          {
            "node": "Insights Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Planning Agent Model": {
      "ai_languageModel": [
        [
          {
            "node": "Planning Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Reporting Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Planning Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Reporting Agent Model": {
      "ai_languageModel": [
        [
          {
            "node": "Reporting Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Metrics Data Sheet Tool": {
      "ai_tool": [
        [
          {
            "node": "Metrics Agent Tool",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Daily Metrics Collection": {
      "main": [
        [
          {
            "node": "Planning Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Planning Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Trend Analysis Code Tool": {
      "ai_tool": [
        [
          {
            "node": "Insights Agent Tool",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}