{
  "name": "iLog - Complaint Router v0.3",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "complaint",
        "responseMode": "onReceived",
        "responseData": "allEntries",
        "options": {
          "rawBody": false
        },
        "authentication": "headerAuth",
        "headerAuth": {
          "name": "X-Hubspot-Signature",
          "value": "whsec_ilog_bruno_2025_NAOTROQUEI"
        }
      },
      "id": "a1b2c3d4-1111-4aaa-aaaa-111111111111",
      "name": "Webhook Hubspot",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "create",
        "model": "gpt-5.4-mini",
        "apiKey": "sk-EXEMPLO-VAZADO-AQUI-bruno-pessoal-NAO-USAR-EM-PROD-1a2b3c4d5e6f7g8h9i0j",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 um classificador de reclama\u00e7\u00f5es de clientes da iLog (logtech brasileira de last-mile delivery). Receba o texto da reclama\u00e7\u00e3o e responda APENAS com uma das quatro categorias exatas (sem explica\u00e7\u00e3o, sem pontua\u00e7\u00e3o extra): Atendimento, Log\u00edstica, Pagamento, Fraude.\n\nDefini\u00e7\u00f5es:\n- Atendimento: tratamento ruim, demora no SAC, comunica\u00e7\u00e3o.\n- Log\u00edstica: pacote n\u00e3o chegou, atraso, avaria, endere\u00e7o.\n- Pagamento: cobran\u00e7a em duplicidade, reembolso, cupom, boleto.\n- Fraude: cobran\u00e7a n\u00e3o reconhecida, golpe, uso indevido de CPF/cart\u00e3o."
            },
            {
              "role": "user",
              "content": "={{$json.body.complaint_text}}"
            }
          ]
        },
        "options": {
          "temperature": 0.1,
          "maxTokens": 8,
          "timeout": 30000
        }
      },
      "id": "b2c3d4e5-2222-4bbb-bbbb-222222222222",
      "name": "OpenAI Classificar",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        480,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "dataType": "string",
        "value1": "={{$json.message.content}}",
        "rules": {
          "rules": [
            {
              "operation": "equal",
              "value2": "Atendimento",
              "output": 0
            },
            {
              "operation": "equal",
              "value2": "Log\u00edstica",
              "output": 1
            },
            {
              "operation": "equal",
              "value2": "Pagamento",
              "output": 2
            },
            {
              "operation": "equal",
              "value2": "Fraude",
              "output": 3
            }
          ]
        },
        "fallbackOutput": 0
      },
      "id": "c3d4e5f6-3333-4ccc-cccc-333333333333",
      "name": "Switch Categoria",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#atd",
        "text": "=:loudspeaker: *Nova reclama\u00e7\u00e3o \u2014 Atendimento*\nCliente: `{{$node[\"Webhook Hubspot\"].json.body.customer_id}}`\n>>> {{$node[\"Webhook Hubspot\"].json.body.complaint_text}}",
        "otherOptions": {
          "link_names": true
        }
      },
      "id": "d4e5f6a7-4444-4ddd-dddd-444444444444",
      "name": "Slack #atd",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        980,
        120
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#log",
        "text": "=:package: *Nova reclama\u00e7\u00e3o \u2014 Log\u00edstica*\nCliente: `{{$node[\"Webhook Hubspot\"].json.body.customer_id}}`\n>>> {{$node[\"Webhook Hubspot\"].json.body.complaint_text}}",
        "otherOptions": {
          "link_names": true
        }
      },
      "id": "e5f6a7b8-5555-4eee-eeee-555555555555",
      "name": "Slack #log",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        980,
        260
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#pag",
        "text": "=:credit_card: *Nova reclama\u00e7\u00e3o \u2014 Pagamento*\nCliente: `{{$node[\"Webhook Hubspot\"].json.body.customer_id}}`\n>>> {{$node[\"Webhook Hubspot\"].json.body.complaint_text}}",
        "otherOptions": {
          "link_names": true
        }
      },
      "id": "f6a7b8c9-6666-4fff-ffff-666666666666",
      "name": "Slack #pag",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        980,
        400
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#fra",
        "text": "=:rotating_light: *Nova reclama\u00e7\u00e3o \u2014 Fraude (PRIORIDADE)*\nCliente: `{{$node[\"Webhook Hubspot\"].json.body.customer_id}}`\n>>> {{$node[\"Webhook Hubspot\"].json.body.complaint_text}}\n\ncc <!subteam^S0FRAUDE>",
        "otherOptions": {
          "link_names": true
        }
      },
      "id": "a7b8c9d0-7777-4aaa-bbbb-777777777777",
      "name": "Slack #fra",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        980,
        540
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook Hubspot": {
      "main": [
        [
          {
            "node": "OpenAI Classificar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Classificar": {
      "main": [
        [
          {
            "node": "Switch Categoria",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Categoria": {
      "main": [
        [
          {
            "node": "Slack #atd",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack #log",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack #pag",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack #fra",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "saveExecutionProgress": true,
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "v0.3.0",
  "id": "ilog-complaint-router",
  "meta": {
    "templateCredsSetupCompleted": false,
    "owner": "bruno.salles@ilog.com.br",
    "lastUpdated": "2026-01-08T19:42:11.000Z",
    "notes": "v0.3 - adicionado canal #fra. TODO trocar API key da OpenAI (t\u00e1 a minha pessoal aqui no JSON, fail) e webhook secret."
  },
  "tags": [
    {
      "name": "prod",
      "id": "1"
    },
    {
      "name": "customer-ops",
      "id": "2"
    }
  ]
}