{
  "name": "Disparo de WhatsApp",
  "nodes": [
    {
      "parameters": {
        "jsCode": "// Fun\u00e7\u00e3o para gerar um n\u00famero aleat\u00f3rio entre 15 e 30\nconst min = 15;\nconst max = 30;\n\n// Gera o n\u00famero aleat\u00f3rio\nconst randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;\n\n// Retorna o n\u00famero aleat\u00f3rio como resultado do node\nreturn { randomNumber };\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -4980,
        580
      ],
      "id": "646f7a0f-f7d9-4f87-9d75-d4c1f1a35139",
      "name": "Random time to wait"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f251e5a2-4e84-44cf-842c-c96a58bef017",
              "name": "email",
              "value": "={{ $('Loop Over Items4').item.json.Email }}",
              "type": "string"
            },
            {
              "id": "f3a19952-8247-4d0b-9fe0-936f4fbeee36",
              "name": "conteudo",
              "value": "={{ $('AI Agent1').item.json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -4160,
        580
      ],
      "id": "a4a0f74c-fedc-417b-be05-e6c4386bd290",
      "name": "Informa\u00e7\u00e3o para envio"
    },
    {
      "parameters": {
        "amount": "={{ $json.randomNumber }}"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -4800,
        580
      ],
      "id": "b7097ce0-f01e-401a-b22c-48315974a9f6",
      "name": "Wait3"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Voc\u00ea \u00e9 um SDR que est\u00e1 enviando a primeira mensagem em prospec\u00e7\u00e3o fria. Analise os dados que chegam at\u00e9 voc\u00ea como Nome da Empresa, Nome do S\u00f3cio, Nicho da Empresa, Site e Instagram, para gerar uma primeira abordagem.\n\nAp\u00f3s a sua primeira mensagem um outro agente vai continuar a conversa com o lead. Portanto desperte a curiosidade na primeira mensagem.",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -4540,
        580
      ],
      "id": "4dabfbad-7293-41e8-a545-70e639b31aa9",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -5420,
        600
      ],
      "id": "d9f45ffd-7dbe-4936-82a4-3f846f083577",
      "name": "Loop Over Items4"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.1,
      "position": [
        -4580,
        800
      ],
      "id": "045c6917-9130-4721-94ce-e0c45a47c3af",
      "name": "OpenAI Chat Model9",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "688d7696-7c30-4e3b-8943-98ffb3a3670a",
      "name": "OpenAI4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -3760,
        820
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "41f979ed-6bc3-4652-a59a-83f26107d74e",
      "name": "Loop Over Items5",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -3340,
        660
      ]
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"messages\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      }\n    }\n  },\n  \"required\": [\"messages\"]\n}"
      },
      "id": "64bff2f3-5bf7-407f-826e-85e92ae5c350",
      "name": "OutputParser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -3640,
        820
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Whatsapp message to be splitted and formated: {{ $json.output }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "=Por favor, gere a sa\u00edda no seguinte formato JSON:\n{\n  \"messages\": [\n    \"splitedMessage\",\n    \"splitedMessage\",\n    \"splitedMessage\"\n  ]\n}\n\nAs mensagens devem ser divididas de forma natural, afinal estamos conversando com um humano, n\u00e3o \u00e9 mesmo?\n\nCertifique-se de que a resposta siga exatamente essa estrutura, incluindo os colchetes e as aspas.\n\n### Jamais separe uma mensagem vazia.\n\n### Certifique-se de que a resposta siga exatamente essa estrutura abaixo, deixando somente entre '*' para negrito e nunca fugindo das demais regras de markdown do whatsapp:\n\t\t\t- *negrito* (substitua '**' por '*')\n\t\t\t- ~tachado~ (caso seja algo que foi exclu\u00eddo ou alterado)\n\t\t\t- _it\u00e1lico_.(extremamente raro)\n            - `link` (usar sempre em todos os links)\n\nTudo o que for link, pode colocar entre \"`\", ou seja, na seguinte formata\u00e7\u00e3o: `www.link.com.br`\n"
            }
          ]
        }
      },
      "id": "5bdf17ba-9a05-4d5a-9a60-98acdc7bc015",
      "name": "Parser  Chain1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.4,
      "position": [
        -3800,
        660
      ]
    },
    {
      "parameters": {
        "content": "",
        "height": 560,
        "width": 1180,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3980,
        380
      ],
      "typeVersion": 1,
      "id": "746163c9-142b-4d08-a8ef-08eb2dfdc647",
      "name": "Sticky Note27"
    },
    {
      "parameters": {
        "content": "# Divis\u00e3o de Mensagens Inteligente - Texto",
        "height": 80,
        "width": 736,
        "color": 4
      },
      "id": "8a92b25e-4362-430b-a732-c565844e753e",
      "name": "Sticky Note28",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3960,
        400
      ]
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "=FEEJO",
        "remoteJid": "={{ $('dados').first().json.telefone }}",
        "messageText": "={{ $json.output }}",
        "options_message": {
          "delay": 1200,
          "linkPreview": false
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        -3120,
        680
      ],
      "id": "4d804a0c-da4c-4271-8b28-06ec9a0d3942",
      "name": "Evolution API7",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "FEEJO",
        "remoteJid": "={{$('dados').first().json.telefone}}",
        "messageText": "={{ $json.output }}",
        "options_message": {
          "delay": 1200
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        -3780,
        500
      ],
      "id": "7d986e62-4e99-4fed-b185-ae3c44284e6e",
      "name": "Evolution API8",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7c4cdb12-9452-42a6-a39a-c268bd38dce1",
              "leftValue": "={{ $json.output.lenght }}",
              "rightValue": 90,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -3940,
        580
      ],
      "id": "3079066e-1167-4df0-84d0-aa686d98eedc",
      "name": "Menos que 240 Caracteres1"
    },
    {
      "parameters": {
        "fieldToSplitOut": "output.messages",
        "options": {
          "destinationFieldName": "output"
        }
      },
      "id": "0399bed9-1a97-453d-a9ce-d7ac013d63d6",
      "name": "Split de Mensagem1",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -3500,
        660
      ]
    },
    {
      "parameters": {
        "amount": 1
      },
      "id": "bc9d7a48-173a-496e-9c85-07f837a9e2d8",
      "name": "1 segundo1",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -2980,
        680
      ]
    },
    {
      "parameters": {
        "content": "",
        "height": 560,
        "width": 1240,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5860,
        380
      ],
      "typeVersion": 1,
      "id": "0265d5fe-a624-421f-b8d3-d5b423b0c227",
      "name": "Sticky Note29"
    },
    {
      "parameters": {
        "content": "# Lista de Disparo",
        "height": 80,
        "width": 356,
        "color": 4
      },
      "id": "42e44eae-7f0c-4262-87ca-ff0bc90d0c7e",
      "name": "Sticky Note30",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -5600,
        400
      ]
    },
    {
      "parameters": {
        "content": "",
        "height": 560,
        "width": 600,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4600,
        380
      ],
      "typeVersion": 1,
      "id": "95017c21-aba2-4a8d-95b3-9e2b9eb104af",
      "name": "Sticky Note34"
    },
    {
      "parameters": {
        "content": "# Prepara a Mensagem",
        "height": 80,
        "width": 416,
        "color": 4
      },
      "id": "01f3b5ca-bf1f-4c9a-8d83-53dd85507f95",
      "name": "Sticky Note35",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -4580,
        400
      ]
    },
    {
      "parameters": {
        "content": "",
        "height": 560,
        "width": 380,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2780,
        380
      ],
      "typeVersion": 1,
      "id": "96b356bf-0fb9-4042-884d-6305a5da2415",
      "name": "Sticky Note36"
    },
    {
      "parameters": {
        "content": "# Atualiza Status",
        "height": 80,
        "width": 296,
        "color": 4
      },
      "id": "1751a67a-5891-4544-bedf-0b566aeb97ed",
      "name": "Sticky Note38",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2760,
        400
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 1,
              "unit": "minutes"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "120yqIZfzCB6FrEjdrorbNCwfxY0s3UGK",
          "mode": "list",
          "cachedResultName": "SDR-FEEJO",
          "cachedResultUrl": "https://drive.google.com/drive/folders/120yqIZfzCB6FrEjdrorbNCwfxY0s3UGK"
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "5af0e77f-92e3-4dd8-a5fc-a95f878cc40b",
      "name": "File Created1",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -5800,
        520
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFile",
        "fileToWatch": {
          "__rl": true,
          "value": "1W_6i0xAuMGfPOa2B35cOIvTveokjs27RAbnBeYchq3s",
          "mode": "list",
          "cachedResultName": "Lista-Prospeccao-SDR-Feejo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1W_6i0xAuMGfPOa2B35cOIvTveokjs27RAbnBeYchq3s/edit?usp=drivesdk"
        }
      },
      "id": "843afdc8-ba14-43c5-9122-660090eb6be4",
      "name": "File Updated1",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -5800,
        720
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Gatilho de Monitoramento",
        "height": 480,
        "width": 213,
        "color": 4
      },
      "id": "74dd4e18-908c-4b5b-aec5-97a59743dd87",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -5840,
        420
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1W_6i0xAuMGfPOa2B35cOIvTveokjs27RAbnBeYchq3s",
          "mode": "list",
          "cachedResultName": "Lista-Prospeccao-SDR-Feejo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1W_6i0xAuMGfPOa2B35cOIvTveokjs27RAbnBeYchq3s/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "P\u00e1gina1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1W_6i0xAuMGfPOa2B35cOIvTveokjs27RAbnBeYchq3s/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -5600,
        600
      ],
      "id": "2a8a7842-70a7-4317-ba8a-739696ea734c",
      "name": "Busca Dados",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b788b56e-e346-4298-9f8f-f6f697c715bc",
              "leftValue": "={{ $json.Status }}",
              "rightValue": "Aguardando",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -5200,
        600
      ],
      "id": "a8599ce7-862d-4b7c-809f-4525898c2cdb",
      "name": "Verifica o Status"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1Rji0bdSG_3EAfFkuKbsar7soSuXXHUbCVqSaeVv2xR4",
          "mode": "list",
          "cachedResultName": "EMAIL EM MASSA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Rji0bdSG_3EAfFkuKbsar7soSuXXHUbCVqSaeVv2xR4/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 2031824652,
          "mode": "list",
          "cachedResultName": "emails",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Rji0bdSG_3EAfFkuKbsar7soSuXXHUbCVqSaeVv2xR4/edit#gid=2031824652"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Busca Dados').item.json.row_number }}",
            "Email": "={{ $('Busca Dados').item.json.Email }}",
            "Status": "Enviado"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -2640,
        640
      ],
      "id": "c845e1d2-0221-41c8-9197-6b12a3f60e28",
      "name": "Atualiza Status",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Random time to wait": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Informa\u00e7\u00e3o para envio": {
      "main": [
        [
          {
            "node": "Menos que 240 Caracteres1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Informa\u00e7\u00e3o para envio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items4": {
      "main": [
        [],
        [
          {
            "node": "Verifica o Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model9": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI4": {
      "ai_languageModel": [
        [
          {
            "node": "Parser  Chain1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items5": {
      "main": [
        [
          {
            "node": "Atualiza Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Evolution API7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OutputParser": {
      "ai_outputParser": [
        [
          {
            "node": "Parser  Chain1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Parser  Chain1": {
      "main": [
        [
          {
            "node": "Split de Mensagem1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evolution API7": {
      "main": [
        [
          {
            "node": "1 segundo1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Menos que 240 Caracteres1": {
      "main": [
        [
          {
            "node": "Evolution API8",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Parser  Chain1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split de Mensagem1": {
      "main": [
        [
          {
            "node": "Loop Over Items5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1 segundo1": {
      "main": [
        [
          {
            "node": "Loop Over Items5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Created1": {
      "main": [
        [
          {
            "node": "Busca Dados",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Updated1": {
      "main": [
        [
          {
            "node": "Busca Dados",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Busca Dados": {
      "main": [
        [
          {
            "node": "Loop Over Items4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verifica o Status": {
      "main": [
        [
          {
            "node": "Random time to wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualiza Status": {
      "main": [
        [
          {
            "node": "Loop Over Items4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "68237b9d-636a-404a-a3f8-ef418bf379cb",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "M7saUK2girScB5YQ",
  "tags": []
}