{
  "name": "teste",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "initialMessages": "Ol\u00e1! \ud83d\udc4b\nComo posso te ajudar?",
        "options": {
          "title": "Ola \ud83d\udc4b"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -560,
        20
      ],
      "id": "82f82e56-e119-42a7-ba05-3744400b9ca1",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Edit Fields').item.json.Mensagem }}",
        "options": {
          "systemMessage": "Voc\u00ea \u00e9 um agente de suporte, seja educado, engra\u00e7ao e utilize emojis."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        480,
        0
      ],
      "id": "62e54572-1bbf-4cf6-b5f4-e44a740f7fb2",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        380,
        220
      ],
      "id": "0bb9f915-65c2-4d49-9c1e-2b0b2ebe4b45",
      "name": "Groq Chat Model",
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "51463003-beb3-42ae-a4ba-66a5436e0501",
              "name": "IdConversa",
              "value": "={{ $json.body.data.key.remoteJid }}",
              "type": "string"
            },
            {
              "id": "2d64eb86-4cf0-46a6-a502-0c308e521f32",
              "name": "Mensagem",
              "value": "={{ $json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "0baaea15-4b18-4111-aa36-2538b4aaf899",
              "name": "Data",
              "value": "={{ $now }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        0
      ],
      "id": "0b9441f1-8900-483f-90d9-91f554f2e13b",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Edit Fields').item.json.IdConversa }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        520,
        220
      ],
      "id": "dddc5d10-79b3-4f94-8dfd-e5e4208d1dca",
      "name": "Simple Memory"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        820,
        220
      ],
      "id": "dce7ab53-a488-4a0c-93a5-a6d03028c745",
      "name": "Calculator"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "typeVersion": 1,
      "position": [
        660,
        220
      ],
      "id": "54d54bee-adbe-4678-acd5-fac518b94b3d",
      "name": "Wikipedia"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        900,
        0
      ],
      "id": "6ec0ae62-06d0-4105-a5ea-55559be1d542",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Edit Webhook').item.json.Mensagem }}",
        "options": {
          "systemMessage": "Voc\u00ea \u00e9 um agente de suporte, seja educado, engra\u00e7ao e utilize emojis."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        500,
        840
      ],
      "id": "71847e79-5973-4389-aec7-ac04aed8acc6",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "sessionIdType": "customKey"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        540,
        1080
      ],
      "id": "fc92b785-c5ac-4cfd-b9ac-e07816488b2e",
      "name": "Simple Memory1"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        840,
        1080
      ],
      "id": "98ede3a9-f288-4c54-8934-93c6709ab47e",
      "name": "Calculator1"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "typeVersion": 1,
      "position": [
        680,
        1080
      ],
      "id": "bff6b5a8-a15b-40bf-8ac4-a2d8aa1a7e86",
      "name": "Wikipedia1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1120,
        840
      ],
      "id": "b6d64c6d-c6b1-4089-8c6e-854e0549dbff",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        60,
        1080
      ],
      "id": "1603a041-f22c-4f2a-82a9-fc64d6a7108d",
      "name": "No Operation, do nothing2"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.z-api.io/instances/SUA_INSTANCIA/token/SEU_TOKEN/send-text",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "client-token",
              "value": "{{security-token}}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "phone",
              "value": "5511999998888"
            },
            {
              "name": "message",
              "value": "Welcome to *Z-API*"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        840
      ],
      "id": "935b9c2d-65cb-48a8-b531-fe25dca98519",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "receber-mensagem-whatsapp",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1060,
        360
      ],
      "id": "15fbcafd-ea19-4ea3-b204-11b211359217",
      "name": "Webhook1"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE",
          "mode": "list",
          "cachedResultName": "CursoN8NGratuito-Tutorial#1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Case 1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZIyZrOkvoxyptGpg0f4Km1FOPQNkEtliXr651pFQyuA/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Mensagem": "={{ $json.Mensagem }}",
            "Data": "={{ $json.Data }}",
            "idConversa": "={{ $json.IdConversa }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "idConversa",
              "displayName": "idConversa",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Mensagem",
              "displayName": "Mensagem",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Data",
              "displayName": "Data",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        240,
        0
      ],
      "id": "945bcff2-29e3-4e5d-96dc-3cffaa47050d",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE",
          "mode": "list",
          "cachedResultName": "CursoN8NGratuito-Tutorial#1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Case1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "idConversa": "={{ $('Webhook1').item.json.body.sender }}",
            "Mensagem": "={{ $('Webhook1').item.json.body.data.message.conversation }}",
            "Data": "={{ $('If-web').item.json.body.date_time }}"
          },
          "matchingColumns": [
            "idConversa"
          ],
          "schema": [
            {
              "id": "idConversa",
              "displayName": "idConversa",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Mensagem",
              "displayName": "Mensagem",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Data",
              "displayName": "Data",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        260,
        840
      ],
      "id": "2d6074ba-b03a-4c2a-a077-808dbbc21c42",
      "name": "Append or update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "n8n",
        "remoteJid": "595993547294",
        "messageText": "={{ $json.output }}",
        "options_message": {}
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        1200,
        0
      ],
      "id": "204a1b31-86fa-4e50-9cf4-141fe591daae",
      "name": "Enviar texto",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.5-pro",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        400,
        1080
      ],
      "id": "f077f5b7-2fde-4bc9-bbf1-e3ecee56ca1c",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3e159d22-1e35-4ac6-b7c4-23dcd61b2c65",
              "leftValue": "={{ $json.body.isGroup }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "b3e67eed-ee63-4f85-9e8c-31cb3c84dea5",
              "leftValue": "={{ $json.body.isNewsletter }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "6ee1e0b8-3aa2-4964-aecd-5c41f7417f56",
              "leftValue": "={{ $json.body.fromApi }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "2288f863-9d64-4a5b-8414-6dc359375d0e",
              "leftValue": "={{ $json.body.broadcast }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "7c0fd32d-bb1c-40ae-be3c-102064ae579a",
              "leftValue": "={{ $json.body.data.key.fromMe }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -780,
        360
      ],
      "id": "86228ed6-44d4-4517-8b92-d00ad9bf6dd9",
      "name": "If1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -700,
        760
      ],
      "id": "b5932be1-cedd-45e6-b71d-9f721eadd1a5",
      "name": "No Operation, do nothing3"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "51463003-beb3-42ae-a4ba-66a5436e0501",
              "name": "IdConversa",
              "value": "={{ $('Webhook1').item.json.body.data.key.remoteJid }}",
              "type": "string"
            },
            {
              "id": "2d64eb86-4cf0-46a6-a502-0c308e521f32",
              "name": "Mensagem",
              "value": "={{ $('Webhook1').item.json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "4d5885bf-d1db-49af-86fb-22b8a5fe81c7",
              "name": "Nome",
              "value": "={{ $('Webhook1').item.json.body.sender }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        60,
        840
      ],
      "id": "ed98cc0c-ae32-4d54-b216-9716db5255e0",
      "name": "Edit Webhook"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3e159d22-1e35-4ac6-b7c4-23dcd61b2c65",
              "leftValue": "={{ $json.body.isGroup }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "b3e67eed-ee63-4f85-9e8c-31cb3c84dea5",
              "leftValue": "={{ $json.body.isNewsletter }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "6ee1e0b8-3aa2-4964-aecd-5c41f7417f56",
              "leftValue": "={{ $json.body.fromApi }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            },
            {
              "id": "2288f863-9d64-4a5b-8414-6dc359375d0e",
              "leftValue": "={{ $json.body.broadcast }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -160,
        840
      ],
      "id": "3d9c8fa8-fd44-4a4c-9085-720259a7e5c3",
      "name": "If-web"
    }
  ],
  "connections": {
    "AI Agent1": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wikipedia": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Calculator1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wikipedia1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        [
          {
            "node": "Enviar texto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          },
          {
            "node": "If-web",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Webhook": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If-web": {
      "main": [
        [
          {
            "node": "Edit Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "93fe5263-b550-4552-a2f0-29355e8fc5f9",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "hpOJdKysOFwrcAhI",
  "tags": [
    {
      "createdAt": "2025-06-30T01:10:28.185Z",
      "updatedAt": "2025-06-30T01:10:28.185Z",
      "id": "MnjNIW7kUF7UYkxw",
      "name": "NoCode StartUp"
    }
  ]
}