{
  "name": "00 - MongoDB setup (indexes)",
  "nodes": [
    {
      "parameters": {},
      "id": "n8n-manual-trigger",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -200,
        0
      ]
    },
    {
      "parameters": {
        "operation": "createIndex",
        "collection": "chat_history",
        "keys": "chat_id:1,date:-1",
        "options": {}
      },
      "id": "n8n-index-chat-id-date",
      "name": "Index chat_id+date",
      "type": "n8n-nodes-base.mongoDb",
      "typeVersion": 1,
      "position": [
        100,
        0
      ],
      "credentials": {
        "mongoDb": {
          "id": "REPLACE_MONGO_CRED_ID",
          "name": "MongoDB - tg_agents"
        }
      }
    },
    {
      "parameters": {
        "operation": "createIndex",
        "collection": "chat_history",
        "keys": "chat_id:1,message_id:1",
        "options": {
          "unique": true
        }
      },
      "id": "n8n-index-unique-message",
      "name": "Index unique message_id",
      "type": "n8n-nodes-base.mongoDb",
      "typeVersion": 1,
      "position": [
        320,
        0
      ],
      "credentials": {
        "mongoDb": {
          "id": "REPLACE_MONGO_CRED_ID",
          "name": "MongoDB - tg_agents"
        }
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Index chat_id+date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Index chat_id+date": {
      "main": [
        [
          {
            "node": "Index unique message_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}