{
  "id": "coBopLGa9cP3cCp0",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Monitoring Business Daily Metrics",
  "tags": [],
  "nodes": [
    {
      "id": "b922d17e-4f70-41b0-a885-4bad99505cc4",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        0,
        0
      ],
      "parameters": {
        "path": "5e2d95f2-a6c7-4ae0-b3bd-c10bde013de9",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "138de074-7f57-43ba-8feb-b7d93026e26a",
      "name": "Save to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        208,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json.body.date }}",
            "New Leads": "={{ $json.body.newLeads }}",
            "Calls Made": "={{ $json.body.callsMade }}",
            "Revenue ($)": "={{ $json.body.revenue }}",
            "Deals Closed": "={{ $json.body.dealsClosed }}",
            "Demos Booked": "={{ $json.body.demosBooked }}"
          },
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "New Leads",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "New Leads",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Calls Made",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Calls Made",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Demos Booked",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Demos Booked",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Deals Closed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Deals Closed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Revenue ($)",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Revenue ($)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "bf661e88-82d8-40c1-837f-e341ceeef8c0",
      "name": "Get All Rows",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        400,
        0
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7365f559-c550-4c35-b276-e01f0115df42",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1088,
        256
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5175473d-5f3d-4771-8373-287b6bbe9897",
      "name": "Generate Insights",
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "position": [
        800,
        0
      ],
      "parameters": {
        "options": {
          "summarizationMethodAndPrompts": {
            "values": {
              "prompt": "Write a concise summary of the daily business metrics, Show the current situation by comparing the latest data to the previous 3 days. The revenue is on dollars. Generate a summary with html format only the body and remove the intro and remove ```html tag because it's not rendered well, show the changes from previous date in percentage and seperate column. this text will attached for the email message:\n\n\n\"{text}\"\n",
              "combineMapPrompt": "Write a concise summary following:\n\n\n\"{text}\"\n\nCONCISE SUMMARY:"
            }
          }
        },
        "chunkSize": 100000
      },
      "typeVersion": 2.1
    },
    {
      "id": "1a0f5b2d-7024-462e-9349-c6e8998c57a9",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1168,
        -256
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Daily Report Summary\n\n{{ $json.output.text }}",
        "options": {},
        "subject": "=Business Metrics - {{ $('Concat Sales Data').item.json.lastDate }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "25589e11-7088-416e-8232-8ccd22c23cc7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -240
      ],
      "parameters": {
        "width": 416,
        "height": 176,
        "content": "## Daily Sales Metrics Auto-Insight\n\nThis workflow automates the process of collecting daily sales metrics from Google Sheets, summarize the insights using Google Gemini model, and sends a concise report to email automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "3b1d401b-18f5-4ffc-95d1-93be8cc6156d",
      "name": "Concat Sales Data",
      "type": "n8n-nodes-base.code",
      "position": [
        576,
        0
      ],
      "parameters": {
        "jsCode": "const data = []\nfor (const item of $input.all()) {\n  data.push({\n    date: `Date: ${item.json.Date}`,\n    newLeads: `New Leads: ${item.json['New Leads']}`,\n    callsMade: `Calls Made: ${item.json['Calls Made']}`,\n    demosBooked: `Demos Booked: ${item.json['Demos Booked']}`,\n    dealsClosed: `Deals Closed: ${item.json['Deals Closed']}`,\n    revenue: `Revenue in $: ${item.json['Revenue ($)']}`\n  })\n}\n\nreturn [\n  {\n    json: {\n      lastDate:$('Webhook').first().json.body.date,\n      data\n    }\n  }\n]"
      },
      "typeVersion": 2
    },
    {
      "id": "a9c81702-a52d-41ec-95b3-cedc6583f6c5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        208
      ],
      "parameters": {
        "color": 7,
        "content": "## Processing Data\n\nConcating data into one string to helping the model generate insights easier"
      },
      "typeVersion": 1
    },
    {
      "id": "6dc8a3b2-bd8d-4055-9e90-0df55b3eeec2",
      "name": "Create a backlog",
      "type": "n8n-nodes-base.trello",
      "position": [
        1792,
        176
      ],
      "parameters": {
        "name": "={{ $workflow.name }}-  {{ $now }}",
        "listId": "66266d87882b20a8324063bc",
        "description": "={{ $json.text }}",
        "additionalFields": {
          "idMembers": "5b90fe107e11f13a69d74fde"
        }
      },
      "credentials": {
        "trelloApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c689b22f-26cf-4699-8f32-661708bdf3cb",
      "name": "Classify Insight",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        1440,
        -16
      ],
      "parameters": {
        "options": {
          "systemPromptTemplate": "Please classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the text with cleared html tag. Clear the html string to get the actual data"
        },
        "inputText": "={{ $json.text }}",
        "categories": {
          "categories": [
            {
              "category": "Good",
              "description": "The revenue has increased by 5% and the demo closed has increased compared to three days ago."
            },
            {
              "category": "Bad",
              "description": "the revenue has decreased by 5% and the deals closed is same compared to three days ago"
            },
            {
              "category": "Very Bad",
              "description": "the revenue has decreased by 15% and deal closed around 0-3 deals compared to three days ago"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e5bf06e8-9531-46fe-a4d9-5eda708cbf6e",
      "name": "Remove HTML Tags",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1136,
        0
      ],
      "parameters": {
        "text": "=clean this text from html tag to retrieve the information. Don't explain, just return the cleaned text following the telegram format message.\n\n{{ $json.output.text }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "407597d8-dbdc-4562-ad4f-f1abda2433a1",
      "name": "Notify Group",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1856,
        -80
      ],
      "parameters": {
        "text": "={{ $workflow.name }}- {{ $now }}\n\nThe performance\n{{ $json.text }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "243e3add-1b8a-47b5-b6b6-fcdf7c687c49",
      "name": "Create a meeting",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1936,
        176
      ],
      "parameters": {
        "end": "={{ $now.plus(25, 'hour') }}",
        "start": "={{ $now.plus(24, 'hours')}}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "summary": "=Business Daily Metrics - {{ $today }}",
          "attendees": [
            "user@example.com"
          ],
          "description": "=Discussing the very bad business daily metrics {{ $json.url }}",
          "guestsCanInviteOthers": true
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "b156c86d-2a06-4795-88a3-13b134c3c50e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        368
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 208,
        "content": "## Creating immediate action\n\nCreate a card backlog, attach to the event description and invite the stakeholders"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8fdcf839-fcbd-4553-874e-385d6358c031",
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Save to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Rows": {
      "main": [
        [
          {
            "node": "Concat Sales Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Sheet": {
      "main": [
        [
          {
            "node": "Get All Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Insight": {
      "main": [
        [
          {
            "node": "Notify Group",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Group",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create a backlog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a backlog": {
      "main": [
        [
          {
            "node": "Create a meeting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove HTML Tags": {
      "main": [
        [
          {
            "node": "Classify Insight",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Concat Sales Data": {
      "main": [
        [
          {
            "node": "Generate Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Insights": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Remove HTML Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Insights",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Classify Insight",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Remove HTML Tags",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}