This workflow follows the HTTP Request → Postgres 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 →
{
"name": "AsaasPagamento",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "asaas",
"options": {}
},
"id": "b8c6f827-89b7-4786-be15-ecea13337297",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
-420,
600
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "=SELECT \"access_tokens\".\"token\" AS \"utoken\" FROM \"account_users\" INNER JOIN \"access_tokens\" ON \"access_tokens\".\"owner_id\" = \"account_users\".\"user_id\" WHERE \"account_users\".\"account_id\" = {{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"conversation\"][\"messages\"][\"0\"][\"account_id\"] }} AND \"access_tokens\".\"owner_type\" = 'User' AND \"account_users\".\"role\" = 1 ORDER BY \"account_users\".\"id\" LIMIT 1;",
"additionalFields": {}
},
"id": "becce4b1-4958-4089-939d-e3aa9d2b4091",
"name": "Informa UToken",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
-200,
600
],
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const tokenUrl = $item(0).$node[\"Ajusta Informa\u00e7\u00e3o\"].json[\"TOKEN\"];\n\n// Use a express\u00e3o regular para encontrar a informa\u00e7\u00e3o ap\u00f3s \"asaastoken=\"\nconst match = tokenUrl.match(/asaastoken=([^&]*)/);\n\nif (match) {\n const asaastoken = match[1];\n return [{ TOKEN: asaastoken }];\n} else {\n console.log(\"asaastoken n\u00e3o encontrado na URL.\");\n return []; // Retorna um array vazio se o asaastoken n\u00e3o for encontrado.\n}\n"
},
"id": "6cca9ff0-2558-4cbf-83c2-d10296d1e19b",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
440,
600
]
},
{
"parameters": {
"url": "=https://chat.cwmkt.com.br/api/v1/accounts/{{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"conversation\"][\"messages\"][\"0\"][\"account_id\"] }}/inboxes/{{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"conversation\"][\"messages\"][\"0\"][\"inbox_id\"] }}",
"sendQuery": true,
"queryParameters": {
"parameters": [
{}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "api_access_token",
"value": "={{ $json.utoken }}"
}
]
},
"options": {}
},
"id": "49d3f7e8-d929-4f8a-8e5b-d2f8ece161d5",
"name": "Consulta Webhook no Chatwoot",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
0,
600
]
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"string": [
{
"name": "TOKEN",
"value": "={{ $json.webhook_url }}"
}
]
},
"options": {}
},
"id": "2167cfb1-b51b-4fa8-8676-69a1e501acdc",
"name": "Ajusta Informa\u00e7\u00e3o",
"type": "n8n-nodes-base.set",
"typeVersion": 2,
"position": [
220,
600
]
},
{
"parameters": {
"url": "https://www.asaas.com/api/v3/customers",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "cpfCnpj",
"value": "={{ $node.CPF.json.cpf }}"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "access_token",
"value": "={{ $json[\"Token Assas\"] }}"
}
]
},
"options": {}
},
"id": "8b247ded-bce1-4be2-8b3e-23896665479b",
"name": "Consulta CPF CNPJ na Asaas",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
1720,
580
]
},
{
"parameters": {
"url": "https://www.asaas.com/api/v3/payments",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "customer",
"value": "={{ $node[\"Consulta CPF CNPJ na Asaas\"].json.data[0].id }}"
},
{
"name": "status",
"value": "PENDING"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "access_token",
"value": "={{ $node[\"Ajusta as Informa\u00e7\u00f5es Asaas\"].json[\"Token Assas\"] }}"
}
]
},
"options": {}
},
"id": "f39d873f-6b79-4ec8-a5fa-a7ad61e18551",
"name": "Consulta Fatura",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
3040,
440
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $item(\"0\").$node[\"Consulta CPF CNPJ na Asaas\"].json[\"data\"][\"0\"][\"email\"] }}",
"operation": "contains",
"value2": "=@"
}
]
}
},
"id": "abdcc85b-7993-4b9f-8408-e83c1a1bc473",
"name": "Valida se existe o Cliente",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
2460,
580
]
},
{
"parameters": {
"conditions": {
"number": [
{
"value1": "={{ $json.totalCount }}",
"operation": "equal",
"value2": 1
}
]
}
},
"id": "e3c94f09-fde9-46a1-9de6-746883aff1b6",
"name": "Valida se existe fatura Existente",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
3260,
440
]
},
{
"parameters": {
"baseUrl": "=http://127.0.0.1:31000",
"token": "={{ $json[\"Token Quepasa\"] }}",
"text": "=\u2705 Localizei seu Cadastro! \n\n\ud83d\udc49 *{{ $item(\"0\").$node[\"Ajusta Informa\u00e7\u00f5es do Quepasa\"].json[\"Nome\"] }}* \n\nVou enviar a pr\u00f3xima fatura.",
"chatId": "={{ $('Webhook').item.json.body.conversation.messages[0].sender.identifier }}"
},
"id": "db424ff7-b261-4d96-b612-14c217a4a1cc",
"name": "Cadastro Localizado",
"type": "n8n-nodes-quepasa.quepasa",
"typeVersion": 1,
"position": [
2780,
440
]
},
{
"parameters": {
"baseUrl": "=http://127.0.0.1:31000",
"token": "={{ $item(\"0\").$node[\"Valida se existe o Cliente\"].json[\"TOKEN\"] }}",
"text": "=\ud83e\uddd1\u200d\ud83d\ude92 Segue a segunda-via da sua Fatura!\n\n\ud83d\udc49 *Fatura:* {{ $item(\"0\").$node[\"Consulta Fatura\"].json[\"data\"][\"0\"][\"invoiceUrl\"] }}\n\n\ud83d\udc49 *Nome:* {{ $item(\"0\").$node[\"Ajusta Informa\u00e7\u00f5es do Quepasa\"].json[\"Nome\"] }}\n\n\ud83d\udc49 *Valor:* R$ {{ $node[\"Consulta Fatura\"].json[\"data\"][0][\"value\"] }},00",
"chatId": "={{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"conversation\"][\"messages\"][\"0\"][\"sender\"][\"identifier\"] }}"
},
"id": "8ef67142-1473-4547-8297-fe67faab5f59",
"name": "Envia Mensagem com a Fatura",
"type": "n8n-nodes-quepasa.quepasa",
"typeVersion": 1,
"position": [
3540,
300
]
},
{
"parameters": {
"baseUrl": "=http://127.0.0.1:31000",
"token": "={{ $item(\"0\").$node[\"Valida se existe o Cliente\"].json[\"TOKEN\"] }}",
"text": "\ud83d\udc49 Voc\u00ea n\u00e3o tem nenhuma fatura vencida!",
"chatId": "={{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"conversation\"][\"messages\"][\"0\"][\"sender\"][\"identifier\"] }}"
},
"id": "5d387a79-f3b5-44de-b84d-f804807c3324",
"name": "Envia Mensagem sem Faturas",
"type": "n8n-nodes-quepasa.quepasa",
"typeVersion": 1,
"position": [
3540,
600
]
},
{
"parameters": {
"conditions": {
"number": [
{
"value1": "={{ $json.quantidade_digitos }}",
"operation": "equal",
"value2": 11
}
]
}
},
"id": "e62fbe7e-acf0-48a9-89f6-8266934ab588",
"name": "Verifica se mensagem e Valida",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1200,
600
],
"continueOnFail": true,
"notes": "Sucesso"
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"string": [
{
"name": "cpf",
"value": "={{ $('Webhook').item.json.body.content }}"
}
]
},
"options": {}
},
"id": "f3d36c16-114e-4836-860d-4bf2b81fce7d",
"name": "CPF",
"type": "n8n-nodes-base.set",
"typeVersion": 2,
"position": [
680,
600
]
},
{
"parameters": {
"jsCode": "// Obter o n\u00famero do CPF ou CNPJ a partir de uma vari\u00e1vel\nconst numero = items[0].json.cpf;\n\n// Remover todos os caracteres especiais do n\u00famero\nconst numeroSemPontuacao = numero.replace(/[^\\d]+/g,'');\n\n// Verificar se o n\u00famero \u00e9 um CPF ou CNPJ v\u00e1lido\nif (numeroSemPontuacao.length === 11) {\n // O n\u00famero \u00e9 um CPF\n return {quantidade_digitos: 11};\n} else if (numeroSemPontuacao.length === 14) {\n // O n\u00famero \u00e9 um CNPJ\n return {quantidade_digitos: 11};\n} else {\n // O n\u00famero n\u00e3o \u00e9 v\u00e1lido\n return {erro: \"O n\u00famero informado n\u00e3o \u00e9 um CPF ou CNPJ v\u00e1lido.\"};\n}\n"
},
"id": "0bf40d36-7e61-4610-bfb3-9695759306a8",
"name": "Verifica CPF ou CNPJ",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [
920,
600
]
},
{
"parameters": {
"baseUrl": "=http://127.0.0.1:31000",
"token": "={{ $item(\"0\").$node[\"Valida se existe o Cliente\"].json[\"TOKEN\"] }}",
"text": "=\u2705 N\u00e3o localizamos seu Cadastro!\n\n\u2705 Por favor, entre em contato o financeiro!",
"chatId": "={{ $item(\"0\").$node[\"Webhook\"].json[\"body\"][\"conversation\"][\"messages\"][\"0\"][\"sender\"][\"identifier\"] }}"
},
"id": "9491d915-aa45-404b-9bb4-72dcd18b90e8",
"name": "Cadastro N\u00e3o Localizado",
"type": "n8n-nodes-quepasa.quepasa",
"typeVersion": 1,
"position": [
2780,
720
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "CPF",
"value": "={{ $node[\"CPF\"].json[\"cpf\"] }}"
},
{
"name": "Token Assas",
"value": "={{ $('Code').item.json.TOKEN }}"
}
]
},
"options": {}
},
"id": "41f3c264-0f79-477f-9c3d-a2c921647298",
"name": "Ajusta as Informa\u00e7\u00f5es Asaas",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
1460,
580
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "Token Quepasa",
"value": "={{ $item(\"0\").$node[\"Code1\"].json[\"TOKEN\"] }}"
},
{
"name": "customer",
"value": "={{ $('Consulta CPF CNPJ na Asaas').item.json.data[0].id }}"
}
],
"number": [
{
"name": "Nome",
"value": "={{ $('Consulta CPF CNPJ na Asaas').item.json.data[0].name }}"
}
]
},
"options": {}
},
"id": "54596933-a5e7-4213-8f4b-fbb1cb3ea2ce",
"name": "Ajusta Informa\u00e7\u00f5es do Quepasa",
"type": "n8n-nodes-base.set",
"typeVersion": 2,
"position": [
2200,
580
]
},
{
"parameters": {
"jsCode": "const tokenUrl = $item(0).$node[\"Ajusta Informa\u00e7\u00e3o\"].json[\"TOKEN\"];\n\n// Use a express\u00e3o regular para encontrar a informa\u00e7\u00e3o ap\u00f3s \"identifier=\"\nconst match = tokenUrl.match(/identifier=([^&]*)/);\n\nif (match) {\n const identifier = match[1];\n return [{ TOKEN: identifier }];\n} else {\n console.log(\"identifier n\u00e3o encontrado na URL.\");\n return []; // Retorna um array vazio se o identifier n\u00e3o for encontrado.\n}\n"
},
"id": "9e020464-93ca-4785-980b-a57797741d60",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1940,
580
]
},
{
"parameters": {
"content": "## (2.0.0) Recommendations \n* Automa\u00e7\u00e3o para segunda via de boleto com ASAAS.",
"width": 395
},
"id": "6ce3c9f3-d8e2-4378-bc90-1f85dd217394",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
720,
40
]
}
],
"connections": {
"Webhook": {
"main": [
[
{
"node": "Informa UToken",
"type": "main",
"index": 0
}
]
]
},
"Informa UToken": {
"main": [
[
{
"node": "Consulta Webhook no Chatwoot",
"type": "main",
"index": 0
}
]
]
},
"Consulta Webhook no Chatwoot": {
"main": [
[
{
"node": "Ajusta Informa\u00e7\u00e3o",
"type": "main",
"index": 0
}
]
]
},
"Ajusta Informa\u00e7\u00e3o": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Consulta Fatura": {
"main": [
[
{
"node": "Valida se existe fatura Existente",
"type": "main",
"index": 0
}
]
]
},
"Consulta CPF CNPJ na Asaas": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Valida se existe o Cliente": {
"main": [
[
{
"node": "Cadastro Localizado",
"type": "main",
"index": 0
}
],
[
{
"node": "Cadastro N\u00e3o Localizado",
"type": "main",
"index": 0
}
]
]
},
"Valida se existe fatura Existente": {
"main": [
[
{
"node": "Envia Mensagem com a Fatura",
"type": "main",
"index": 0
}
],
[
{
"node": "Envia Mensagem sem Faturas",
"type": "main",
"index": 0
}
]
]
},
"Cadastro Localizado": {
"main": [
[
{
"node": "Consulta Fatura",
"type": "main",
"index": 0
}
]
]
},
"Verifica se mensagem e Valida": {
"main": [
[
{
"node": "Ajusta as Informa\u00e7\u00f5es Asaas",
"type": "main",
"index": 0
}
]
]
},
"CPF": {
"main": [
[
{
"node": "Verifica CPF ou CNPJ",
"type": "main",
"index": 0
}
]
]
},
"Verifica CPF ou CNPJ": {
"main": [
[
{
"node": "Verifica se mensagem e Valida",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "CPF",
"type": "main",
"index": 0
}
]
]
},
"Ajusta as Informa\u00e7\u00f5es Asaas": {
"main": [
[
{
"node": "Consulta CPF CNPJ na Asaas",
"type": "main",
"index": 0
}
]
]
},
"Ajusta Informa\u00e7\u00f5es do Quepasa": {
"main": [
[
{
"node": "Valida se existe o Cliente",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Ajusta Informa\u00e7\u00f5es do Quepasa",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "3d3872cf-b083-4c41-8526-b938901db98d",
"id": "6UtNV3Zk5mbCq7p3",
"tags": [
{
"createdAt": "2023-09-15T00:59:45.759Z",
"updatedAt": "2023-09-15T00:59:45.759Z",
"id": "VNEiAJqFxqpORliZ",
"name": "cwmkt"
},
{
"createdAt": "2023-09-15T00:59:51.235Z",
"updatedAt": "2023-09-15T00:59:51.235Z",
"id": "vvysJMRHVKf2sZES",
"name": "2.0"
},
{
"createdAt": "2023-08-22T20:29:16.268Z",
"updatedAt": "2023-08-22T20:29:16.268Z",
"id": "1SwThJSvuVO2ge7p",
"name": "QUEPASA"
},
{
"createdAt": "2023-08-22T20:29:16.268Z",
"updatedAt": "2023-08-22T20:29:16.268Z",
"id": "10yNytp7vaqToroj",
"name": "CHATWOOT"
}
]
}
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.
postgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
AsaasPagamento. Uses postgres, httpRequest, n8n-nodes-quepasa. Webhook trigger; 20 nodes.
Source: https://github.com/comunidadehubconnect/segundaviaasaas/blob/b46236f04f6778b6217c2c90505ccb36524cef4b/Workflows/AsaasPagamento.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
CMM. Uses httpRequest, postgres, redis. Webhook trigger; 90 nodes.
Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.
Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.
LogSentinel Workflow. Uses postgres, emailSend, httpRequest. Webhook trigger; 44 nodes.
Post-Prayer. Uses postgres, httpRequest. Webhook trigger; 44 nodes.