AutomationFlowsMarketing & Ads › Kreativ: Lead Scoring

Kreativ: Lead Scoring

Kreativ: Lead Scoring. Uses executeWorkflowTrigger, postgres, httpRequest. Webhook trigger; 8 nodes.

Webhook trigger★★★★☆ complexity8 nodesExecute Workflow TriggerPostgresHTTP Request
Marketing & Ads Trigger: Webhook Nodes: 8 Complexity: ★★★★☆ Added:

This workflow follows the Execute Workflow Trigger → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Kreativ: Lead Scoring",
  "nodes": [
    {
      "id": "wh-module-completed",
      "name": "Webhook: m\u00f3dulo conclu\u00eddo",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        200
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "lead-scoring",
        "responseMode": "onReceived",
        "options": {}
      }
    },
    {
      "id": "trigger-sub",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1,
      "position": [
        240,
        400
      ],
      "parameters": {}
    },
    {
      "id": "code-normalize",
      "name": "Normalizar Entrada",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "jsCode": "const input = $input.item.json;\nconst phone = String(input.phone ?? input.body?.phone ?? '').replace(/\\D/g, '');\nconst moduleNumber = parseInt(String(input.moduleNumber ?? input.moduleId ?? input.body?.moduleNumber ?? '0'), 10);\nconst points = parseInt(String(input.points ?? input.body?.points ?? '20'), 10);\nconst tag = input.tag ?? input.body?.tag ?? null;\nreturn [{ json: { body: { phone, moduleNumber, points, tag } } }];"
      }
    },
    {
      "id": "pg-lead-scoring",
      "name": "Calcular e salvar lead score",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2,
      "position": [
        680,
        300
      ],
      "parameters": {
        "operation": "executeQuery",
        "query": "UPDATE students SET\n  lead_score = LEAST(100, \n    CASE \n      WHEN {{ $json.body.moduleNumber }} > 0 THEN (\n        SELECT ROUND((COALESCE(array_length(completed_modules, 1), 0)::float / NULLIF((SELECT COUNT(*) FROM modules WHERE course_id = students.course_id::text), 0)) * 100)\n      )\n      ELSE lead_score + {{ $json.body.points }}\n    END\n  ),\n  lead_tags = CASE \n    WHEN '{{ $json.body.tag }}' != 'null' AND '{{ $json.body.tag }}' != '' THEN ARRAY_APPEND(ARRAY_REMOVE(lead_tags, '{{ $json.body.tag }}'), '{{ $json.body.tag }}')\n    ELSE lead_tags\n  END,\n  updated_at = NOW()\nWHERE phone = '{{ $json.body.phone }}'\nRETURNING phone, lead_score, name;",
        "options": {}
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true
    },
    {
      "id": "code-score-msg",
      "name": "Formatar mensagem conquista",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ],
      "parameters": {
        "jsCode": "const norm = $('Normalizar Entrada').item.json.body;\nconst phone = norm.phone;\nconst moduleNumber = norm.moduleNumber;\nconst score = $input.all()[0]?.json?.lead_score ?? 0;\n\nlet emoji = '\u2b50';\nif (score >= 100) emoji = '\ud83c\udfc6';\nelse if (score >= 75) emoji = '\ud83e\udd47';\nelse if (score >= 50) emoji = '\ud83e\udd48';\nelse if (score >= 25) emoji = '\ud83e\udd49';\n\nconst msg = `${emoji} *Parab\u00e9ns!*\\n\\nVoc\u00ea concluiu o M\u00f3dulo ${moduleNumber} com sucesso!\\nSeu progresso atual: *${score}%*\\n\\nContinue assim! \ud83d\ude80`;\n\nreturn [{ json: { phone, message: msg, score } }];"
      }
    },
    {
      "id": "http-wapp-congratulation",
      "name": "Enviar parab\u00e9ns WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1120,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "http://kreativ_evolution:8080/message/sendText/europs",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "EXr5OuEE2sBMbRo94LtWQfofvEF1gHUM"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ number: $json.phone, text: $json.message }) }}"
      },
      "continueOnFail": true
    },
    {
      "id": "http-update-label",
      "name": "Atualizar Label Chatwoot",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1120,
        500
      ],
      "parameters": {
        "method": "POST",
        "url": "http://localhost:5678/webhook/update-chatwoot-label",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ phone: $json.phone, module_number: $('Normalizar Entrada').item?.json?.body?.moduleNumber }) }}"
      },
      "continueOnFail": true
    },
    {
      "id": "respond-ok",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1350,
        300
      ],
      "parameters": {
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook: m\u00f3dulo conclu\u00eddo": {
      "main": [
        [
          {
            "node": "Normalizar Entrada",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Normalizar Entrada",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalizar Entrada": {
      "main": [
        [
          {
            "node": "Calcular e salvar lead score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calcular e salvar lead score": {
      "main": [
        [
          {
            "node": "Formatar mensagem conquista",
            "type": "main",
            "index": 0
          },
          {
            "node": "Atualizar Label Chatwoot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Formatar mensagem conquista": {
      "main": [
        [
          {
            "node": "Enviar parab\u00e9ns WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar parab\u00e9ns WhatsApp": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar Label Chatwoot": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Kreativ: Lead Scoring. Uses executeWorkflowTrigger, postgres, httpRequest. Webhook trigger; 8 nodes.

Source: https://github.com/RAFAELUFT22/kreativ_bot_v2/blob/2e44f13e3eab55e41e825bf59bca063e04a97b1a/n8n-workflows/11-lead-scoring.json — original creator credit. Request a take-down →

More Marketing & Ads workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Marketing & Ads

Enrich person L3. Uses executeWorkflowTrigger, postgres, perplexity, httpRequest. Webhook trigger; 12 nodes.

Execute Workflow Trigger, Postgres, Perplexity +1
Marketing & Ads

This workflow automates bulk email campaigns with built-in validation, deliverability protection, and smart send-time optimization.

HTTP Request, Postgres, Gmail
Marketing & Ads

get-data-for-marketting-dashboard. Uses postgres, googleAnalytics, httpRequest. Webhook trigger; 20 nodes.

Postgres, Google Analytics, HTTP Request
Marketing & Ads

Enrich company L1. Uses executeWorkflowTrigger, postgres, perplexity. Webhook trigger; 9 nodes.

Execute Workflow Trigger, Postgres, Perplexity
Marketing & Ads

User Integration Setup. Uses httpRequest, postgres. Webhook trigger; 5 nodes.

HTTP Request, Postgres