{
  "name": "GYRA+ | 2. Receber Decis\u00e3o \u2192 Rotear para CRM",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83d\udcec GYRA+ | Workflow 2: Receber Decis\u00e3o \u2192 Rotear para CRM\n\n**O que este workflow faz:**\n1. Recebe o webhook da GYRA+ quando o relat\u00f3rio \u00e9 conclu\u00eddo\n2. Responde 200 OK imediatamente (boa pr\u00e1tica \u2014 n\u00e3o deixe o webhook aguardar)\n3. Extrai `policyStatus`, `score` e dados do relat\u00f3rio\n4. Roteia para 3 caminhos: APPROVED, DENIED ou ALERT\n5. Atualiza o registro no seu CRM via HTTP\n6. Envia notifica\u00e7\u00e3o para o respons\u00e1vel comercial\n\n**Pr\u00e9-requisito:**\nRegistre a URL deste webhook na GYRA+:\n```\nPOST /webhook\n{ \"url\": \"https://seu-n8n.com/webhook/gyra-decisao\" }\n```\n\nOu use o **Workflow 1** que j\u00e1 inclui registro autom\u00e1tico.",
        "height": 348,
        "width": 532,
        "color": 5
      },
      "id": "49be1ad4-2c1a-4001-a314-1c7ddc18051e",
      "name": "\ud83d\udccb Sobre este Workflow",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "content": "## \u2699\ufe0f Configure suas Credenciais\n\nSubstitua os valores abaixo:\n- `crmWebhookUrl` \u2192 URL do webhook do seu CRM para atualizar neg\u00f3cios\n- `notificationWebhookUrl` \u2192 Slack, Teams ou outro canal de notifica\u00e7\u00e3o\n- `crmApiKey` \u2192 API Key do seu CRM (se necess\u00e1rio)\n\n**CRMs compat\u00edveis:**\nHubSpot, Pipedrive, RD Station, Salesforce, Bitrix24, Monday.com",
        "height": 316,
        "width": 444,
        "color": 4
      },
      "id": "7c5aeb9d-df5b-4402-9b53-a79674b5dcc0",
      "name": "\u2699\ufe0f Nota de Configura\u00e7\u00e3o",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        592,
        0
      ]
    },
    {
      "parameters": {
        "content": "## \u2705 Branch APPROVED\n\nCliente aprovado!\n- Score acima da faixa m\u00ednima\n- Sem restri\u00e7\u00f5es cr\u00edticas\n\nA\u00e7\u00f5es sugeridas:\n- Atualizar neg\u00f3cio no CRM para \"Aprovado\"\n- Definir prazo de pagamento automaticamente\n- Notificar time de vendas para fechar contrato",
        "height": 296,
        "width": 364,
        "color": 3
      },
      "id": "395ba762-6262-4d49-a072-e44b3e3fbfef",
      "name": "\u2705 Nota APPROVED",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1728,
        -64
      ]
    },
    {
      "parameters": {
        "content": "## \u26a0\ufe0f Branch ALERT\n\nCliente em an\u00e1lise manual!\n- Score na faixa intermedi\u00e1ria\n- H\u00e1 pend\u00eancias que precisam de revis\u00e3o humana\n\nA\u00e7\u00f5es sugeridas:\n- Atualizar CRM para \"Em An\u00e1lise\"\n- Notificar analista de cr\u00e9dito\n- Enviar lista de pend\u00eancias encontradas",
        "height": 296,
        "width": 348,
        "color": 4
      },
      "id": "6adc3471-0022-450a-b81a-af2ad9bd3538",
      "name": "\u26a0\ufe0f Nota ALERT",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1744,
        304
      ]
    },
    {
      "parameters": {
        "content": "## \u274c Branch DENIED\n\nCliente reprovado!\n- Score abaixo do limite m\u00ednimo, ou\n- Regra de exclus\u00e3o ativada (san\u00e7\u00f5es, PEP, etc.)\n\nA\u00e7\u00f5es sugeridas:\n- Atualizar CRM para \"Reprovado\"\n- Arquivar lead por 90 dias\n- Notificar vendedor com motivo gen\u00e9rico (LGPD)",
        "height": 264,
        "width": 364
      },
      "id": "b11a71a2-a7a6-470e-9406-1562d150f9ad",
      "name": "\u274c Nota DENIED",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1744,
        688
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "gyra-decisao",
        "options": {
          "noResponseBody": false
        }
      },
      "id": "b14a0c04-f986-45e1-92ee-6cbc4783dd36",
      "name": "\ud83d\udcec Receber Webhook GYRA+",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        368
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cfg-crm-url",
              "name": "crmWebhookUrl",
              "value": "https://SEU-CRM.com/webhook/atualizar-negocio",
              "type": "string"
            },
            {
              "id": "cfg-crm-key",
              "name": "crmApiKey",
              "value": "SUA_API_KEY_CRM_AQUI",
              "type": "string"
            },
            {
              "id": "cfg-notif-url",
              "name": "notificationWebhookUrl",
              "value": "https://hooks.slack.com/services/SEU_WEBHOOK_SLACK_AQUI",
              "type": "string"
            },
            {
              "id": "cfg-gyra-url",
              "name": "apiBaseUrl",
              "value": "https://gyra-core.gyramais.com.br",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "2fbae240-5f2e-4c49-8b74-2f36e7fd480e",
      "name": "\u2699\ufe0f CONFIGURE AQUI",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        320,
        368
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ext-report-id",
              "name": "reportId",
              "value": "={{ $('\ud83d\udcec Receber Webhook GYRA+').item.json.reportId }}",
              "type": "string"
            },
            {
              "id": "ext-document",
              "name": "document",
              "value": "={{ $('\ud83d\udcec Receber Webhook GYRA+').item.json.document }}",
              "type": "string"
            },
            {
              "id": "ext-status",
              "name": "policyStatus",
              "value": "={{ $('\ud83d\udcec Receber Webhook GYRA+').item.json.policyStatus }}",
              "type": "string"
            },
            {
              "id": "ext-score",
              "name": "score",
              "value": "={{ $('\ud83d\udcec Receber Webhook GYRA+').item.json.score }}",
              "type": "number"
            },
            {
              "id": "ext-type",
              "name": "reportType",
              "value": "={{ $('\ud83d\udcec Receber Webhook GYRA+').item.json.type }}",
              "type": "string"
            },
            {
              "id": "ext-external-id",
              "name": "externalId",
              "value": "={{ $('\ud83d\udcec Receber Webhook GYRA+').item.json.externalId || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "7193ee1f-2dea-4d56-9dbc-3140dc343218",
      "name": "\ud83d\udcca Extrair Dados da Decis\u00e3o",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        672,
        368
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.policyStatus }}",
                    "rightValue": "APPROVED",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "APPROVED"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.policyStatus }}",
                    "rightValue": "ALERT",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "ALERT"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.policyStatus }}",
                    "rightValue": "DENIED",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "DENIED"
            }
          ]
        },
        "options": {}
      },
      "id": "30092e4c-aeed-4eda-8061-14c7440cfbb0",
      "name": "\ud83d\udd00 Rotear por Decis\u00e3o",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        960,
        368
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.crmWebhookUrl }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.crmApiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"externalId\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.externalId }}\",\n  \"document\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.document }}\",\n  \"reportId\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.reportId }}\",\n  \"creditStatus\": \"APROVADO\",\n  \"score\": {{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }},\n  \"action\": \"MOVE_TO_PROPOSAL\",\n  \"notes\": \"An\u00e1lise GYRA+ aprovada automaticamente. Score: {{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }}/1000\"\n}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "b63bba59-b38b-44dc-abf7-62a72315bce9",
      "name": "\u2705 Atualizar CRM \u2192 APROVADO",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1264,
        208
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.notificationWebhookUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"\u2705 *Cr\u00e9dito APROVADO* \u2014 CNPJ/CPF: `{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.document }}` | Score: *{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }}/1000* | Relat\u00f3rio: `{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.reportId }}`\"\n}",
        "options": {}
      },
      "id": "178d67b6-904c-4692-8875-9796e185f907",
      "name": "\ud83d\udd14 Notificar Equipe \u2192 Aprovado",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1552,
        208
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.crmWebhookUrl }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.crmApiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"externalId\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.externalId }}\",\n  \"document\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.document }}\",\n  \"reportId\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.reportId }}\",\n  \"creditStatus\": \"EM_ANALISE\",\n  \"score\": {{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }},\n  \"action\": \"ASSIGN_TO_ANALYST\",\n  \"notes\": \"An\u00e1lise GYRA+ em alerta \u2014 revis\u00e3o manual necess\u00e1ria. Score: {{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }}/1000. Acesse o relat\u00f3rio completo no Toolbox.\"\n}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "16887293-8f2e-4e86-8065-d9305d0b1c12",
      "name": "\u26a0\ufe0f Atualizar CRM \u2192 EM AN\u00c1LISE",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1264,
        368
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.notificationWebhookUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"\u26a0\ufe0f *Cr\u00e9dito em AN\u00c1LISE MANUAL* \u2014 CNPJ/CPF: `{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.document }}` | Score: *{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }}/1000* | Atribu\u00eddo ao analista de cr\u00e9dito. Relat\u00f3rio: `{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.reportId }}`\"\n}",
        "options": {}
      },
      "id": "59da7e03-b631-4758-aaed-8cefac0600ab",
      "name": "\ud83d\udd14 Notificar Analista \u2192 Alerta",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1552,
        368
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.crmWebhookUrl }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.crmApiKey }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"externalId\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.externalId }}\",\n  \"document\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.document }}\",\n  \"reportId\": \"{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.reportId }}\",\n  \"creditStatus\": \"REPROVADO\",\n  \"score\": {{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }},\n  \"action\": \"ARCHIVE_LEAD\",\n  \"notes\": \"An\u00e1lise GYRA+ reprovada automaticamente. Score: {{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }}/1000. Lead arquivado por 90 dias.\"\n}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "b243c6e8-0eed-4321-957a-e8e439bf02b0",
      "name": "\u274c Atualizar CRM \u2192 REPROVADO",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1264,
        528
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.notificationWebhookUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"\u274c *Cr\u00e9dito REPROVADO* \u2014 CNPJ/CPF: `{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.document }}` | Score: *{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.score }}/1000* | Lead arquivado automaticamente. Relat\u00f3rio: `{{ $('\ud83d\udcca Extrair Dados da Decis\u00e3o').item.json.reportId }}`\"\n}",
        "options": {}
      },
      "id": "b534c3b7-3d24-4459-b40b-bc60339cfcc2",
      "name": "\ud83d\udd14 Notificar Equipe \u2192 Reprovado",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1552,
        528
      ]
    }
  ],
  "connections": {
    "\ud83d\udcec Receber Webhook GYRA+": {
      "main": [
        [
          {
            "node": "\u2699\ufe0f CONFIGURE AQUI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2699\ufe0f CONFIGURE AQUI": {
      "main": [
        [
          {
            "node": "\ud83d\udcca Extrair Dados da Decis\u00e3o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcca Extrair Dados da Decis\u00e3o": {
      "main": [
        [
          {
            "node": "\ud83d\udd00 Rotear por Decis\u00e3o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd00 Rotear por Decis\u00e3o": {
      "main": [
        [
          {
            "node": "\u2705 Atualizar CRM \u2192 APROVADO",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u26a0\ufe0f Atualizar CRM \u2192 EM AN\u00c1LISE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u274c Atualizar CRM \u2192 REPROVADO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2705 Atualizar CRM \u2192 APROVADO": {
      "main": [
        [
          {
            "node": "\ud83d\udd14 Notificar Equipe \u2192 Aprovado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u26a0\ufe0f Atualizar CRM \u2192 EM AN\u00c1LISE": {
      "main": [
        [
          {
            "node": "\ud83d\udd14 Notificar Analista \u2192 Alerta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u274c Atualizar CRM \u2192 REPROVADO": {
      "main": [
        [
          {
            "node": "\ud83d\udd14 Notificar Equipe \u2192 Reprovado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "5891ab46-33e6-45e9-8017-3fd992848460",
  "id": "5Ocrts18zyRyFD7g",
  "tags": [
    {
      "name": "GYRA+",
      "id": "4nExL8DDYTQeWziF",
      "updatedAt": "2026-03-01T18:30:06.922Z",
      "createdAt": "2026-03-01T18:30:06.922Z"
    },
    {
      "name": "Cr\u00e9dito",
      "id": "pEHOqPPHPfVf3CTJ",
      "updatedAt": "2026-03-01T18:30:07.161Z",
      "createdAt": "2026-03-01T18:30:07.161Z"
    }
  ]
}