{
  "nodes": [
    {
      "id": "fcda047d-b609-4791-b3ae-f359d0c6a071",
      "name": "stats_aggregate_creators",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "={ { $json.path } }{ { $json['creators-filename'] } }.json",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "fa1f51fd-6019-4d47-b17e-8c5621e6ab4c",
      "name": "stats_aggregate_workflows",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "={ { $json.path } }{ { $json['workflows-filename'] } }.json",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "34c2d0d3-0474-4a69-b1a5-14c9021865cd",
      "name": "Global Variables",
      "type": "n8n-nodes-base.set",
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4bcb91c6-d250-4cb4-8ee1-022df13550e1",
              "name": "path",
              "type": "string",
              "value": "https://raw.githubusercontent.com/teds-tech-talks/n8n-community-leaderboard/refs/heads/main/"
            },
            {
              "id": "a910a798-0bfe-41b1-a4f1-41390c7f6997",
              "name": "workflows-filename",
              "type": "string",
              "value": "=stats_aggregate_workflows"
            },
            {
              "id": "e977e816-dc1e-43ce-9393-d6488e6832ca",
              "name": "creators-filename",
              "type": "string",
              "value": "=stats_aggregate_creators"
            },
            {
              "id": "14233ab4-3fa4-4e26-8032-6ffe26cb601e",
              "name": "datetime",
              "type": "string",
              "value": "={ { $now.format('yyyy-MM-dd') } }"
            },
            {
              "id": "f63dc683-a430-43ec-9c25-53fa5c0a3ced",
              "name": "username",
              "type": "string",
              "value": "={ { $json.query.username } }"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b21c51fa-c9b3-4c88-ba7b-fe8a97a951c9",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "c25ff9ea-1905-4bf0-ac71-5d81c25466b7",
      "name": "gpt-4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0.1
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d26278f5-08d8-4640-82a6-1c3615b6f06b",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"query\": \n    {\n      \"username\": \n      \"joe\"\n    }\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "7e830263-746f-4909-87aa-5e602d39fc3a",
      "name": "Parse Workflow Data",
      "type": "n8n-nodes-base.set",
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "76f4b20e-519e-4d46-aeac-c6c3f98a69fd",
              "name": "data",
              "type": "array",
              "value": "={ { $json.data } }"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b112dde6-9194-451f-9c5e-b3f648d215da",
      "name": "Parse Creators Data",
      "type": "n8n-nodes-base.set",
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "76f4b20e-519e-4d46-aeac-c6c3f98a69fd",
              "name": "data",
              "type": "array",
              "value": "={ { $json.data } }"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1d223053-d895-4545-a9b2-6eeab6200568",
      "name": "Filter By Creator Username",
      "type": "n8n-nodes-base.filter",
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "21b17fb0-1809-4dc0-b775-cf43a570aa3a",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={ { $json.username } }",
              "rightValue": "={ { $('Global Variables').item.json.username } }"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0e2507bf-4509-4423-ad23-bee9de2be68e",
      "name": "Save creator-summary.md",
      "type": "n8n-nodes-base.readWriteFile",
      "parameters": {
        "options": {
          "append": true
        },
        "fileName": "=C:\\\\Users\\\\joe\\Downloads\\\\{ { $binary.data.fileName } }-{ { $now.format('yyyy-MM-dd-hh-mm-ss') } }.md",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "6c07ee44-408f-4d4a-bade-e051d780d022",
      "name": "Summary Report",
      "type": "n8n-nodes-base.set",
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c44ee9a7-e640-4f5e-acbe-ec559868b74c",
              "name": "output",
              "type": "string",
              "value": "={ { $json.output } }"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "99078ba8-612d-494a-976a-15f2065754ed",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "bc8ea963-a57d-44f1-bcd4-36a1dcb34f0a",
      "name": "n8n Creator Stats Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "parameters": {
        "text": "={ { $json.chatInput } }",
        "options": {
          "systemMessage": "=You are tasked with generating a **comprehensive Markdown report** about a specific n8n community workflow contributor using the provided tools. Your report should not only address the user's query but also provide meaningful insights into the contributor's impact on the n8n community. Follow the structure below:\n\n## Detailed Summary\n- Provide a thorough summary of the contributor's workflows.\n- Highlight unique features, key use cases, and notable technical components for each workflow.\n\n## Workflows\nCreate a well-formatted markdown table with these columns:\n- **Workflow Name**: The name of the workflow.  Keep the emojies of they exist.\n- **Description**: A brief overview of its purpose and functionality.\n- **Unique Weekly Visitors**: The number of unique users who visited this workflow weekly.\n- **Unique Monthly Visitors**: The number of unique users who visited this workflow monthly.\n- **Unique Weekly Inserters**: The number of unique users who inserted this workflow weekly.\n- **Unique Monthly Inserters**: The number of unique users who inserted this workflow monthly.\n- **Why It’s Popular**: Explain what makes this workflow stand out (e.g., innovative features, ease of use, specific use cases).\n\n## Community Analysis\n- Analyze why these workflows are popular and valued by the n8n community.\n- Discuss any trends, patterns, or feedback that highlight their significance.\n\n## Additional Insights\n- If available, provide extra information about the contributor's overall impact, such as their engagement in community forums or other notable contributions.\n\n## Formatting Guidelines\n- Use Markdown formatting exclusively (headers, lists, and tables) for clarity and organization.\n- Ensure your response is concise yet comprehensive, structured for easy navigation.\n\n## Error Handling\n- If data is unavailable or incomplete, clearly state this in your response and suggest possible reasons or next steps.\n\n## TOOLS\n\n### n8n_creator_stats  \n- Use this tool to retrieve detailed statistics about the n8n creator.\n\n\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "4ea35ccb-a4f4-481c-9122-6fc980be48d5",
      "name": "Workflow Tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "parameters": {
        "name": "n8n_creator_stats",
        "workflowId": "={ { $workflow.id } }",
        "description": "Call this tool to get n8n Creator Stats.",
        "jsonSchemaExample": "{\n  \"username\": \"n8n creator username\"\n}",
        "specifyInputSchema": true
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "stats_aggregate_creators": {
      "main": [
        [
          {
            "node": "Parse Creators Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "stats_aggregate_workflows": {
      "main": [
        [
          {
            "node": "Parse Workflow Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Global Variables": {
      "main": [
        [
          {
            "node": "stats_aggregate_creators",
            "type": "main",
            "index": 0
          },
          {
            "node": "stats_aggregate_workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "n8n Creator Stats Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gpt-4o-mini": {
      "ai_languageModel": [
        [
          {
            "node": "n8n Creator Stats Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Filter By Creator Username": {
      "main": [
        [
          {
            "node": "Parse Creators Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save creator-summary.md": {
      "main": [
        [
          {
            "node": "Summary Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}