{
  "name": "Nola_case",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "nolan",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -672,
        304
      ],
      "id": "5232e310-d8a2-4f60-94a1-33770407e87d",
      "name": "Webhook"
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('defineMensagem').item.json.instancia }}",
        "remoteJid": "={{ $('defineMensagem').item.json.numeroDestino }}",
        "messageText": "={{ $json.resposta }}",
        "options_message": {
          "delay": 1200,
          "linkPreview": true
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        1584,
        288
      ],
      "id": "80fd672f-a44e-4179-8b5d-e39332181d5b",
      "name": "Enviar texto",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7d06dfcd-93a8-4cf2-97f1-b256fd0432e6",
              "name": "tipoMensagem",
              "value": "={{ $json.body.data.messageType }}",
              "type": "string"
            },
            {
              "id": "4eb7779f-03a6-4e97-8af0-74e466f17cf9",
              "name": "eu",
              "value": "={{ $json.body.data.key.fromMe }}",
              "type": "boolean"
            },
            {
              "id": "673ead25-f961-46f2-85a6-1ca952eb30a1",
              "name": "instancia",
              "value": "={{ $json.body.instance }}",
              "type": "string"
            },
            {
              "id": "03dead15-e866-4fc7-8b13-89bdca16533e",
              "name": "nome",
              "value": "={{ $json.body.data.pushName }}",
              "type": "string"
            },
            {
              "id": "e729d0de-6a98-45d1-9c0f-3d3e331ab2c2",
              "name": "numeroDestino",
              "value": "={{ $json.body.data.key.remoteJid }}",
              "type": "string"
            },
            {
              "id": "c1807ea5-6058-4f6f-9ff6-73e5141766f9",
              "name": "numeroEnvio",
              "value": "={{ $json.body.sender }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -496,
        304
      ],
      "id": "5780ddbd-b3df-478d-a3c7-8c3eba135204",
      "name": "Dados"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.numeroDestino }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        528,
        592
      ],
      "id": "66b28a9f-7d92-4d38-b22d-9342c200afb0",
      "name": "Mem\u00f3ria de chats"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.mensagem }}",
        "options": {
          "systemMessage": "=Voc\u00ea \u00e9 Nolan um assistente virtual da nola e do arcca. Voc\u00ea deve ser educado, simp\u00e1tico e o mais humanizado o possivel orientando tirando qualquer duvida que o usu\u00e1rio possa ter. Tente gerar respostas naturais e n\u00e3o muito extensas, a n\u00e3o ser que o usu\u00e1rio solicite.\n\na formata\u00e7\u00e3o deve siguir exatamente o modelo no link https://faq.whatsapp.com/539178204879377/?helpref=uf_share\n\nNome do cliente:  {{ $json.nome }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        432,
        272
      ],
      "id": "d72d1191-a737-456f-bb08-5aa9ac48e58f",
      "name": "Agente de IA"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        416,
        512
      ],
      "id": "59470977-0f32-4c76-9017-563289007a99",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        96,
        736
      ],
      "id": "8270f8c0-d302-4f2b-acac-0a91226418f7",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "eec2fd0c-63ce-420c-b000-16e8b25cf5a3",
              "leftValue": "={{ $json.numeroEnvio }}",
              "rightValue": "={{ $json.numeroDestino }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "30913686-676f-4673-98fb-f1ec31c22be4",
              "leftValue": "={{ $json.eu }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -352,
        304
      ],
      "id": "5792003d-35ca-43a6-9223-2c7904c1bfae",
      "name": "If",
      "notes": "Duas condic\u00f5es uma para veriificar se fui eu que enviei a mensagem, a outra para garantir que foi para meu proprio numero(para o agente n\u00e3o me responder em outras conversar)"
    },
    {
      "parameters": {
        "fieldToSplitOut": "resposta",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1168,
        272
      ],
      "id": "8abf3d8e-5943-4151-b11e-0850c86031da",
      "name": "Split Out"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1360,
        272
      ],
      "id": "e5fba51a-b695-498b-9f83-3788bf77b9db",
      "name": "Loop Over Items"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1584,
        112
      ],
      "id": "4f1e71af-2ddb-4308-a717-5c28a89a5c66",
      "name": "No Operation, do nothing2"
    },
    {
      "parameters": {
        "amount": 2
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1744,
        288
      ],
      "id": "fe2eb626-626e-4f66-ad89-b15fc193ec2b",
      "name": "Wait"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.tipoMensagem }}",
                    "rightValue": "conversation",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "c19810a1-7af2-4f1a-9196-15729d73e2f9"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "texto"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "7753a36d-f8e6-41d8-b42c-58776cb4d075",
                    "leftValue": "={{ $json.tipoMensagem }}",
                    "rightValue": "audioMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "audio"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        -128,
        288
      ],
      "id": "b22413d9-15c2-47fb-b268-5d50e65f8732",
      "name": "Switch"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "893ca5ab-154f-457d-92ec-f4f176c48c8e",
              "name": "mensagem",
              "value": "={{ $('Webhook').item.json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "9d2e1f95-9c68-425f-8bb1-121591bbd7cd",
              "name": "tipoMensagem",
              "value": "={{ $json.tipoMensagem }}",
              "type": "string"
            },
            {
              "id": "59f265cc-4fe9-4254-9ebe-fa11a578cfae",
              "name": "eu",
              "value": "={{ $json.eu }}",
              "type": "boolean"
            },
            {
              "id": "79a3546a-4cf0-4417-a18b-b9e455db88c8",
              "name": "instancia",
              "value": "={{ $json.instancia }}",
              "type": "string"
            },
            {
              "id": "6314bbf3-824d-47fc-92e4-dc5fc5034e70",
              "name": "nome",
              "value": "={{ $json.nome }}",
              "type": "string"
            },
            {
              "id": "dad15f46-76ab-41b8-b1b4-e924f281e284",
              "name": "numeroDestino",
              "value": "={{ $json.numeroDestino }}",
              "type": "string"
            },
            {
              "id": "e88feb1c-acaa-4efd-a922-8a27aba52121",
              "name": "numeroEnvio",
              "value": "={{ $json.numeroEnvio }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        96,
        272
      ],
      "id": "edf37d2e-482b-42bd-93e0-f08381e07ce6",
      "name": "defineMensagem"
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "={{ $('Dados').item.json.instancia }}",
        "remoteJid": "={{ $('Dados').item.json.numero }}",
        "messageText": "Poxa vida, infelizmente eu ainda n\u00e3o consigo processar \u00e1udios! Por favor, entre com texto, para que eu possa te ajudar.",
        "options_message": {}
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        128,
        448
      ],
      "id": "99e34b77-9c3f-42eb-b258-779ffde95e27",
      "name": "Enviar texto1",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0a01f8eb-d06e-4d95-bc9c-20a364cca93d",
              "name": "output",
              "value": "={{ $json.output.replaceAll('**','*') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        864,
        272
      ],
      "id": "e53af54c-48fc-4491-8631-6b8aac8f7f15",
      "name": "formatandoTexto"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8d78addb-b185-4153-b458-8e013f8853e2",
              "name": "resposta",
              "value": "={{ $json.output.split('\\n\\n')}}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1008,
        272
      ],
      "id": "1d8234a3-e009-4fa1-b4ad-df0989e17658",
      "name": "definindoResposta"
    },
    {
      "parameters": {
        "toolDescription": "Sobre a historia completa do grupo Arcca",
        "url": "https://arcca.io/sobre-nos/",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        768,
        768
      ],
      "id": "a1f1a2be-476c-463c-bc49-0f1b85eea6ac",
      "name": "historiaArcca"
    },
    {
      "parameters": {
        "toolDescription": "Sobre a Arcca e seus servi\u00e7os",
        "url": "https://arcca.io/",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        672,
        768
      ],
      "id": "020b8ff3-cb58-4716-8262-1204a5195da4",
      "name": "sobreArcca"
    },
    {
      "parameters": {
        "toolDescription": "sobre o Nola",
        "url": "https://usenola.com.br/",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        864,
        608
      ],
      "id": "1d17a88c-30b5-443d-9ff5-b1aa781550e1",
      "name": "sobreNola"
    },
    {
      "parameters": {
        "toolDescription": "mais informa\u00e7\u00f5es sobre franqueadores",
        "url": "https://usenola.com.br/nola-para-franqueadores/",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        1008,
        608
      ],
      "id": "8e18b205-6365-42b4-bb46-9bb5c3e7c97b",
      "name": "franquiasNola"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Dados",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mem\u00f3ria de chats": {
      "ai_memory": [
        [
          {
            "node": "Agente de IA",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Agente de IA": {
      "main": [
        [
          {
            "node": "formatandoTexto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agente de IA",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Enviar texto": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar texto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "defineMensagem",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar texto1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar texto1": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "defineMensagem": {
      "main": [
        [
          {
            "node": "Agente de IA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "formatandoTexto": {
      "main": [
        [
          {
            "node": "definindoResposta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "definindoResposta": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "historiaArcca": {
      "ai_tool": [
        [
          {
            "node": "Agente de IA",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "sobreArcca": {
      "ai_tool": [
        [
          {
            "node": "Agente de IA",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "sobreNola": {
      "ai_tool": [
        [
          {
            "node": "Agente de IA",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "franquiasNola": {
      "ai_tool": [
        [
          {
            "node": "Agente de IA",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3e73dd5d-6313-4fca-8d5d-44a85a86a9e5",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "O5ll2ZAcbHbUhsuX",
  "tags": []
}