{
  "name": "Conversational Razorpay Analytics with Google Gemini & Telegram Bot",
  "nodes": [
    {
      "id": "24fb0a57-8288-4202-8189-26f054e76366",
      "name": "Fetch all orders",
      "type": "@razorpay/n8n-nodes-razorpay.razorpay",
      "position": [
        1744,
        800
      ]
    },
    {
      "id": "4d710956-539f-4f6c-909b-f1769a3ef451",
      "name": "Orders",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1440,
        816
      ]
    },
    {
      "id": "924333db-90fa-4959-8c22-286a9fc6e959",
      "name": "Refunds",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1424,
        1200
      ]
    },
    {
      "id": "29280a55-d2de-45cc-baa4-c2fa1ad85767",
      "name": "Fetch all refunds",
      "type": "@razorpay/n8n-nodes-razorpay.razorpay",
      "position": [
        1744,
        1184
      ]
    },
    {
      "id": "39e8c434-58ae-4a97-92f5-6955679ccf1b",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1920,
        320
      ]
    },
    {
      "id": "938cecc1-9dcc-4277-a0bb-5d851a51db00",
      "name": "Payments Processor",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1408,
        336
      ]
    },
    {
      "id": "27065e48-142d-481e-82b8-c775e3dee8d1",
      "name": "Fetch all payments",
      "type": "@razorpay/n8n-nodes-razorpay.razorpay",
      "position": [
        1728,
        320
      ]
    },
    {
      "id": "ee4d9592-c463-4035-94de-603f2980fd49",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2384,
        1280
      ]
    },
    {
      "id": "d6bc3c05-e376-445c-81b4-408159e63784",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -16,
        1232
      ]
    },
    {
      "id": "78484f00-2185-4c76-892f-95ce19fb8b24",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -144,
        272
      ],
      "parameters": {
        "width": 2832,
        "height": 1816,
        "content": "# 🤖 PayInsighter - Razorpay Analytics Bot\n### **Purpose:** Intelligent Telegram bot that analyzes Razorpay payment data using AI\n\n## **Flow:**\n### 1. User sends query via Telegram\n### 2. AI classifies"
      }
    },
    {
      "id": "a2cac016-baf8-4b24-803a-e0d514e69ef0",
      "name": "Entry Point",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        880
      ],
      "parameters": {
        "width": 320,
        "height": 632,
        "content": "## 📱 Entry Point\n\n**Telegram Trigger**\n- Listens for incoming Telegram messages\n- Captures user queries about Razorpay analytics\n- Triggers the workflow on every new message\n\n**Output:** User message "
      }
    },
    {
      "id": "bfa56cf0-baaf-4285-8445-146df6944a64",
      "name": "Intent Classification",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        880
      ],
      "parameters": {
        "width": 340,
        "height": 636,
        "content": "## 🧠 Intent Classification\n\n**Intent Classifier**\n- Analyzes user message using Google Gemini\n- Classifies into 4 categories:\n  • payments\n  • orders\n  • refunds\n  • general_chat\n- Supports multi-inte"
      }
    },
    {
      "id": "46c6cae8-4fb5-454c-8e9a-1f63b676071d",
      "name": "Routing Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        304
      ],
      "parameters": {
        "width": 360,
        "height": 1724,
        "content": "## 🔀 Routing Logic\n\n**4 IF Nodes (Parallel Routing)**\n- If: Checks if intent contains \"payments\"\n- If1: Checks if intent contains \"refunds\"\n- If2: Checks if intent contains \"orders\"\n- If3: Checks if i"
      }
    },
    {
      "id": "b869fce0-ab44-4896-9f54-59ff50b9e9db",
      "name": "Payments Branch",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        304
      ],
      "parameters": {
        "width": 1180,
        "height": 408,
        "content": "## 💳 Payments Branch\n\n**Step 1: Payments Processor (AI Agent)**\n- Parses user query for date ranges\n- Generates JSON with from/to/skip/count parameters\n- Date format: \"2025-11-07 00:00:00\"\n\n**Step 2: "
      }
    },
    {
      "id": "3bc21646-d19b-46de-be59-27d7e2bb44c4",
      "name": "Orders Branch",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        768
      ],
      "parameters": {
        "width": 1180,
        "height": 360,
        "content": "## 📦 Orders Branch\n\n**Step 1: Orders (AI Agent)**\n- Parses user query for date ranges\n- Generates JSON with from/to/skip/count parameters\n- Max count: 100 records\n\n**Step 2: Fetch all orders (Razorpay"
      }
    },
    {
      "id": "bcb5d118-63e2-4014-9133-90441189f9ff",
      "name": "Refunds Branch",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        1152
      ],
      "parameters": {
        "width": 1180,
        "height": 424,
        "content": "## 💰 Refunds Branch\n\n**Step 1: Refunds (AI Agent)**\n- Parses user query for date ranges\n- Generates JSON with epoch timestamps\n- Parameters: from/to/skip/count\n\n**Step 2: Fetch all refunds (Razorpay A"
      }
    },
    {
      "id": "c38aa794-edcd-4b7c-88ed-ac479d29b908",
      "name": "General Chat Branch",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        1600
      ],
      "parameters": {
        "width": 1176,
        "height": 420,
        "content": "## 💬 General Chat Branch\n\n**General Chat Processor (AI Agent)**\n- Handles non-analytics queries\n- Responds as PayInsighter bot\n- Provides helpful, concise answers\n- No Razorpay API calls needed\n\n**Use"
      }
    },
    {
      "id": "a934a1f6-604b-40ea-8b68-5c7474968f28",
      "name": "Response Consolidation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2224,
        304
      ],
      "parameters": {
        "width": 424,
        "height": 1712,
        "content": "## 🔗 Response Consolidation\n\n**Merge Node**\n- Combines outputs from all 4 branches\n- Handles multi-intent responses\n- Appends mode: preserves all responses\n\n**Send a text message (Telegram)**\n- Sends "
      }
    },
    {
      "id": "fee560fd-4d41-4012-8d1b-00da357cfa56",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1728,
        576
      ]
    },
    {
      "id": "903d0a39-4cc0-4c9e-ad9a-a2a80bce5d33",
      "name": "Intent Classifier",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        320,
        1312
      ]
    },
    {
      "id": "fd260caf-e5e0-49b0-ade2-156696db0fc9",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1744,
        1008
      ]
    },
    {
      "id": "8a0adced-6494-489b-917c-2e77048d3a32",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1744,
        1424
      ]
    },
    {
      "id": "04a134ed-aa63-46c3-83c3-95a898f4ba53",
      "name": "Google Gemini Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1760,
        1872
      ]
    },
    {
      "id": "bd72f597-0760-4179-814f-7d9770606149",
      "name": "Order Processing Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1920,
        800
      ]
    },
    {
      "id": "eadf3819-6333-4228-97f8-53907b449f8b",
      "name": "Refund Processing Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1936,
        1184
      ]
    },
    {
      "id": "a5699ab2-27ad-4492-81f4-7320a4605350",
      "name": "General Chat Processing Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1760,
        1712
      ]
    },
    {
      "id": "a2287dd8-a411-40d1-855d-8539d7036aae",
      "name": "Merge Responses",
      "type": "n8n-nodes-base.merge",
      "position": [
        2320,
        704
      ]
    },
    {
      "id": "1e3a8db8-5b53-453e-8100-469018453833",
      "name": "Payment Branch",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        704
      ]
    },
    {
      "id": "a423c44e-9488-4aa7-bc1c-7f4ad25a24ca",
      "name": "Order Branch",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        992
      ]
    },
    {
      "id": "560540df-6efa-4f96-8246-c6eacf30ae95",
      "name": "Refund Branch",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        1376
      ]
    },
    {
      "id": "d5dea4b5-08f4-4a4a-8bed-2d02e4b2ffe9",
      "name": "General Chat Branch1",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        1744
      ]
    },
    {
      "id": "2d4d4cad-7258-4444-98bd-489d0755f10b",
      "name": "AI Model Provider",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        1568
      ],
      "parameters": {
        "width": 724,
        "height": 464,
        "content": "## 🤖 AI Model Provider\n\n**Google Gemini Chat Model**\n- Model: gemini-2.5-flash (Or any other model)\n- Powers all 8 AI agents in workflow\n- Handles:\n  • Intent classification\n  • Query parameter extrac"
      }
    }
  ],
  "connections": {
    "Orders": {
      "main": [
        [
          {
            "node": "Fetch all orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refunds": {
      "main": [
        [
          {
            "node": "Fetch all refunds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Branch": {
      "main": [
        [
          {
            "node": "Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refund Branch": {
      "main": [
        [
          {
            "node": "Refunds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Payment Branch": {
      "main": [
        [
          {
            "node": "Payments Processor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Responses": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch all orders": {
      "main": [
        [
          {
            "node": "Order Processing Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Intent Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch all refunds": {
      "main": [
        [
          {
            "node": "Refund Processing Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Classifier": {
      "main": [
        [
          {
            "node": "Payment Branch",
            "type": "main",
            "index": 0
          },
          {
            "node": "Refund Branch",
            "type": "main",
            "index": 0
          },
          {
            "node": "Order Branch",
            "type": "main",
            "index": 0
          },
          {
            "node": "General Chat Branch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch all payments": {
      "main": [
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Payments Processor": {
      "main": [
        [
          {
            "node": "Fetch all payments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "General Chat Branch1": {
      "main": [
        [
          {
            "node": "General Chat Processing Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Processing Agent": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Refund Processing Agent": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Orders",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Order Processing Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Payments Processor",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Refunds",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Refund Processing Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "General Chat Processing Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "General Chat Processing Agent": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 3
          }
        ]
      ]
    }
  }
}