{
  "name": "curso-orig",
  "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": [
        -540,
        80
      ],
      "id": "acfb2be3-6023-49f1-954b-fded53584b82",
      "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": [
        700,
        0
      ],
      "id": "0cd51f50-9506-4d0b-ba8f-7ac6eccbd329",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        600,
        220
      ],
      "id": "7b78407a-c4e3-492f-8285-9a88a0284992",
      "name": "Groq Chat Model",
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "51463003-beb3-42ae-a4ba-66a5436e0501",
              "name": "IdConversa",
              "value": "={{ $json.sessionId }}",
              "type": "string"
            },
            {
              "id": "2d64eb86-4cf0-46a6-a502-0c308e521f32",
              "name": "Mensagem",
              "value": "={{ $json.chatInput }}",
              "type": "string"
            },
            {
              "id": "8d36b1be-7bc3-4c8a-a765-1eacee3923eb",
              "name": "Data",
              "value": "={{ $now }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "id": "b509f982-91d1-4097-87a5-74e8244dfb87",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Edit Fields').item.json.IdConversa }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        740,
        220
      ],
      "id": "d8abb519-9882-4e7a-bf54-175e287386ee",
      "name": "Simple Memory"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        1020,
        220
      ],
      "id": "97338d06-c42e-49e3-9322-60f469a259e8",
      "name": "Calculator"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "typeVersion": 1,
      "position": [
        880,
        220
      ],
      "id": "8999ce70-ace3-4492-94fd-f1ac2d97cc7d",
      "name": "Wikipedia"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1100,
        0
      ],
      "id": "b68daa68-6ab4-44e7-8ae1-32f0f6cc8ddb",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Edit Fields1').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": [
        720,
        840
      ],
      "id": "931cf173-665b-4987-9dcf-db8f5a7b8a6e",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        620,
        1060
      ],
      "id": "5bc643b7-3fd4-4401-b9ef-fab7fdabd3d8",
      "name": "Groq Chat Model1",
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "51463003-beb3-42ae-a4ba-66a5436e0501",
              "name": "IdConversa",
              "value": "={{ $('Webhook').item.json.body.data.key.remoteJid }}",
              "type": "string"
            },
            {
              "id": "2d64eb86-4cf0-46a6-a502-0c308e521f32",
              "name": "Mensagem",
              "value": "={{ $('Webhook').item.json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "4d5885bf-d1db-49af-86fb-22b8a5fe81c7",
              "name": "Nome",
              "value": "={{ $('Webhook').item.json.body.data.pushName }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        280,
        840
      ],
      "id": "2f79b419-d3b5-405e-b685-8a6bd08b7998",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Edit Fields1').item.json.IdConversa }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        760,
        1060
      ],
      "id": "7017852a-c363-447f-a42e-4997ceff730b",
      "name": "Simple Memory1"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        1040,
        1060
      ],
      "id": "ddb99802-b762-4d7e-8f76-100c1289683d",
      "name": "Calculator1"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "typeVersion": 1,
      "position": [
        900,
        1060
      ],
      "id": "43bbe16f-b44a-4d28-a9c3-c7238095f52e",
      "name": "Wikipedia1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1320,
        840
      ],
      "id": "a22e1c09-a4c7-4269-9835-52a284aeac3f",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "receber-mensagem-whatsapp",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -140,
        840
      ],
      "id": "45347e95-ed02-4a85-ba81-7140b4e872e8",
      "name": "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": [
        60,
        840
      ],
      "id": "f3384f37-88fc-42d4-8d89-fbc1fb3f67a6",
      "name": "If"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        280,
        1060
      ],
      "id": "213ee3ad-2df0-4a98-a58d-a2a9018e5ae7",
      "name": "No Operation, do nothing2"
    },
    {
      "parameters": {
        "url": "https://server.senaia.uk/api/v0/senaia",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "phone",
              "value": "5511995009969"
            },
            {
              "name": "message",
              "value": "Welcome to *Z-API*"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1080,
        840
      ],
      "id": "ed2f17fe-d2a7-4741-b851-ae62e100c234",
      "name": "HTTP Request"
    },
    {
      "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": "Case1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "idConversa": "={{ $json.IdConversa }}",
            "Mensagem": "={{ $json.Mensagem }}",
            "Data": "={{ $json.Data }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "idConversa",
              "displayName": "idConversa",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "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": [
        460,
        0
      ],
      "id": "e45d66a4-12ae-4bf6-8e82-beb7aa651258",
      "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": 1507862667,
          "mode": "list",
          "cachedResultName": "Case2",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fhsa6tUsbsIcK6Ub0wHkXTdGFmluMYrQaSAgyvG-BrE/edit#gid=1507862667"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "IdConversa": "={{ $json.IdConversa }}",
            "Mensagem": "={{ $json.Mensagem }}",
            "Nome": "={{ $json.Nome }}"
          },
          "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": "Nome",
              "displayName": "Nome",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        480,
        840
      ],
      "id": "8a9d4b74-5c44-455d-8480-fa95db9e4eef",
      "name": "Append or update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    },
    "Groq Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "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
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "No Operation, do nothing1",
            "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
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2cee566e-9a82-4292-af65-9296da53e6e9",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "SzdNXAuhuwumljvT",
  "tags": [
    {
      "createdAt": "2025-06-30T01:10:28.185Z",
      "updatedAt": "2025-06-30T01:10:28.185Z",
      "id": "MnjNIW7kUF7UYkxw",
      "name": "NoCode StartUp"
    }
  ]
}