{
  "name": "whats",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "webhook",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "id": "241e8880-f8b3-457c-9197-e3fd1ddb9c8c",
      "name": "Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1d05353-cc22-4725-aef3-4c9274ffd909",
              "name": "session",
              "value": "={{ $json.body.session }}",
              "type": "string"
            },
            {
              "id": "3d90735c-c445-4451-aa8a-7b6824a6e13b",
              "name": "chatId",
              "value": "={{ $json.body.payload.from }}",
              "type": "string"
            },
            {
              "id": "9ef030a8-241a-49a2-bc38-63cd9193ae4e",
              "name": "pushName",
              "value": "={{ $json.body.payload._data.Info.PushName }}",
              "type": "string"
            },
            {
              "id": "5491c39e-d931-4f58-860a-5103429c7f1a",
              "name": "paylod_id",
              "value": "={{ $json.body.payload.id }}",
              "type": "string"
            },
            {
              "id": "4dfac49f-6655-4bb3-abdf-e59d9102f88a",
              "name": "event",
              "value": "={{ $json.body.event }}",
              "type": "string"
            },
            {
              "id": "55e8f807-34f5-4ae2-9807-feed9e5299f5",
              "name": "message",
              "value": "={{ $json.body }}",
              "type": "string"
            },
            {
              "id": "c2f4b3d2-e0a4-4938-9eb3-7c616f0c8907",
              "name": "fromMe",
              "value": "={{ $json.body.payload.fromMe }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "id": "cb7edc85-c493-4233-ab09-f823e139f623",
      "name": "FiltrarDados"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.event }}",
                    "rightValue": "message",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "d9d3d991-974f-4c0e-a86b-d6ea42869a07"
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        440,
        0
      ],
      "id": "37432a48-5d04-4684-ab45-c247323318d5",
      "name": "Switch"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "Voce \u00e9 um arquiteto de software com muita experi\u00eancia, e trabalha como consultor de TI, respondendo d\u00favidas sobre conceitos importantes de programa\u00e7\u00e3o, arquitetura de software, clould e devops. "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        620,
        0
      ],
      "id": "79b3de6c-4688-41fe-868f-77ba7bb98db3",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {
          "temperature": 0.4
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        560,
        320
      ],
      "id": "cf2af3c3-5907-4b3f-97e5-3155cd697d7d",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('FiltrarDados').item.json.chatId }}",
        "sessionTTL": 3600,
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryRedisChat",
      "typeVersion": 1.5,
      "position": [
        720,
        320
      ],
      "id": "46a4d691-518f-4101-b00c-f631b50c46db",
      "name": "Redis Chat Memory",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Send Seen",
        "session": "={{ $('FiltrarDados').item.json.session }}",
        "chatId": "={{ $('FiltrarDados').item.json.chatId }}",
        "messageId": "={{ $('FiltrarDados').item.json.paylod_id }}",
        "requestOptions": {}
      },
      "type": "n8n-nodes-waha.WAHA",
      "typeVersion": 202411,
      "position": [
        980,
        0
      ],
      "id": "3027c127-2caa-4f99-b430-9290576941f7",
      "name": "WAHA",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Send Text",
        "session": "={{ $('FiltrarDados').item.json.session }}",
        "chatId": "={{ $('FiltrarDados').item.json.chatId }}",
        "text": "={{ $('AI Agent').item.json.output }}",
        "requestOptions": {}
      },
      "type": "n8n-nodes-waha.WAHA",
      "typeVersion": 202411,
      "position": [
        1200,
        0
      ],
      "id": "48a5ed56-6d57-486a-ac38-0d636a4516a1",
      "name": "WAHA1",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "FiltrarDados",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FiltrarDados": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Redis Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "WAHA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WAHA": {
      "main": [
        [
          {
            "node": "WAHA1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8fa8eccb-eada-4703-9f9c-9f38c10d8365",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "nGlIlquhqusIaxEJ",
  "tags": []
}