8
n8n 中文网amn8n.com

使用CNPJ API和Google Sheets丰富巴西公司数据

中级

这是一个Lead Generation, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 Set, Limit, Telegram, HttpRequest, GoogleSheets 等节点。 使用CNPJ API和Google Sheets丰富巴西公司数据

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "eObdW8oqxSRIvxi2",
  "meta": {
    "instanceId": "943057ae9865dd2906869d78fba63cb807e3403d288699c0026d3aaf59867c7a",
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "nodes": [
    {
      "id": "4a712b97-03ff-4f47-b17a-d2db1730cd4b",
      "name": "手动执行工作流",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -368,
        176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a6a2f770-8850-49f5-a475-8069d852f35d",
      "name": "设置",
      "type": "n8n-nodes-base.set",
      "position": [
        -112,
        176
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "dc5f25ff-443b-42b9-be1f-2299632c747c",
              "name": "telegram_id",
              "type": "string",
              "value": "YOUR_TELEGRAM_ID"
            },
            {
              "id": "2c3806e7-5ef5-450a-a9cb-bc688b3e38cf",
              "name": "api_base_url",
              "type": "string",
              "value": "https://minhareceita.org/"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5ce78f98-1dcf-4048-bb3e-8c038470e991",
      "name": "循环 CNPJs",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        496,
        176
      ],
      "parameters": {
        "options": {},
        "batchSize": 100
      },
      "typeVersion": 3
    },
    {
      "id": "4e6e8675-949d-4a39-b779-efc3738a5445",
      "name": "发送 API 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        304
      ],
      "parameters": {
        "url": "={{ $('Settings').item.json.api_base_url }}{{ $json.cnpj }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "bcfd66a0-8e12-41b0-a87e-067bbe79dc30",
      "name": "在表格中更新 CNPJ 信息",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1136,
        304
      ],
      "parameters": {
        "columns": {
          "value": {
            "uf": "={{ $json.uf }}",
            "cep": "={{ $json.cep }}",
            "pais": "={{ $json.pais }}",
            "email": "={{ $json.email }}",
            "porte": "={{ $json.porte }}",
            "bairro": "={{ $json.bairro }}",
            "numero": "={{ $json.numero }}",
            "ddd_fax": "={{ $json.ddd_fax }}",
            "municipio": "={{ $json.municipio }}",
            "logradouro": "={{ $json.logradouro }}",
            "row_number": "={{ $('Loop CNPJs').item.json.row_number }}",
            "codigo_pais": "={{ $json.codigo_pais }}",
            "complemento": "={{ $json.complemento }}",
            "codigo_porte": "={{ $json.codigo_porte }}",
            "razao_social": "={{ $json.razao_social }}",
            "nome_fantasia": "={{ $json.nome_fantasia }}",
            "capital_social": "={{ $json.capital_social }}",
            "ddd_telefone_1": "={{ $json.ddd_telefone_1 }}",
            "ddd_telefone_2": "={{ $json.ddd_telefone_2 }}",
            "codigo_municipio": "={{ $json.codigo_municipio }}",
            "natureza_juridica": "={{ $json.natureza_juridica }}",
            "codigo_municipio_ibge": "={{ $json.codigo_municipio_ibge }}",
            "nome_cidade_no_exterior": "={{ $json.nome_cidade_no_exterior }}",
            "descricao_tipo_de_logradouro": "={{ $json.descricao_tipo_de_logradouro }}"
          },
          "schema": [
            {
              "id": "cnpj",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "cnpj",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "razao_social",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "razao_social",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "nome_fantasia",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "nome_fantasia",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "capital_social",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "capital_social",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "porte",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "porte",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "codigo_porte",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "codigo_porte",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "uf",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "uf",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "municipio",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "municipio",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "codigo_municipio",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "codigo_municipio",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "codigo_municipio_ibge",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "codigo_municipio_ibge",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bairro",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "bairro",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "logradouro",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "logradouro",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "descricao_tipo_de_logradouro",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "descricao_tipo_de_logradouro",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "numero",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "numero",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "complemento",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "complemento",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "cep",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "cep",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pais",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "pais",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "codigo_pais",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "codigo_pais",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "nome_cidade_no_exterior",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "nome_cidade_no_exterior",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ddd_telefone_1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ddd_telefone_1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ddd_telefone_2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ddd_telefone_2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ddd_fax",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ddd_fax",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "natureza_juridica",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "natureza_juridica",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "codigo_natureza_juridica",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "codigo_natureza_juridica",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "cnae_fiscal",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "cnae_fiscal",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "cnae_fiscal_descricao",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "cnae_fiscal_descricao",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "cnaes_secundarios",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "cnaes_secundarios",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "regime_tributario",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "regime_tributario",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "qualificacao_do_responsavel",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "qualificacao_do_responsavel",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "situacao_cadastral",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "situacao_cadastral",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "descricao_situacao_cadastral",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "descricao_situacao_cadastral",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "motivo_situacao_cadastral",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "motivo_situacao_cadastral",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "descricao_motivo_situacao_cadastral",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "descricao_motivo_situacao_cadastral",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "situacao_especial",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "situacao_especial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "identificador_matriz_filial",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "identificador_matriz_filial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "descricao_identificador_matriz_filial",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "descricao_identificador_matriz_filial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ente_federativo_responsavel",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ente_federativo_responsavel",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_inicio_atividade",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_inicio_atividade",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_situacao_cadastral",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_situacao_cadastral",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_situacao_especial",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_situacao_especial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "opcao_pelo_mei",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "opcao_pelo_mei",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_opcao_pelo_mei",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_opcao_pelo_mei",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_exclusao_do_mei",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_exclusao_do_mei",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "opcao_pelo_simples",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "opcao_pelo_simples",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_opcao_pelo_simples",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_opcao_pelo_simples",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data_exclusao_do_simples",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data_exclusao_do_simples",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "qsa",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "qsa",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Y5GlbWxbWD8zCnB8-vJIlTVtrWEqztyTXeaE6OTuY8s/edit#gid=0",
          "cachedResultName": "Página1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Y5GlbWxbWD8zCnB8-vJIlTVtrWEqztyTXeaE6OTuY8s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Y5GlbWxbWD8zCnB8-vJIlTVtrWEqztyTXeaE6OTuY8s/edit?usp=drivesdk",
          "cachedResultName": "Planilha sem título"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ZhVoDN9ufnYKR8Jv",
          "name": "Google Sheets VIKTHYR"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9aa7367f-4a85-4007-a482-4828fd276654",
      "name": "完成时通知",
      "type": "n8n-nodes-base.telegram",
      "position": [
        976,
        -112
      ],
      "webhookId": "62ebc9be-d3bb-475e-898b-dc43479e3772",
      "parameters": {
        "text": "=CNPJ info extraction complete!",
        "chatId": "={{ $('Settings').item.json.telegram_id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "g96RKSo0I2Vcf1oP",
          "name": "Telegram N8N VIKTHYR Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bdb3fd23-cedc-43d9-872f-32bf099c4665",
      "name": "限制通知器交互",
      "type": "n8n-nodes-base.limit",
      "position": [
        704,
        -112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "6a1ba7c8-9358-46db-be11-21d98ab87506",
      "name": "获取表格中的所有 CNPJs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        224,
        176
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "razao_social"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Y5GlbWxbWD8zCnB8-vJIlTVtrWEqztyTXeaE6OTuY8s/edit#gid=0",
          "cachedResultName": "Página1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Y5GlbWxbWD8zCnB8-vJIlTVtrWEqztyTXeaE6OTuY8s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Y5GlbWxbWD8zCnB8-vJIlTVtrWEqztyTXeaE6OTuY8s/edit?usp=drivesdk",
          "cachedResultName": "Planilha sem título"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ZhVoDN9ufnYKR8Jv",
          "name": "Google Sheets VIKTHYR"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "573946b9-f954-4b25-b039-0631abd131a1",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 336,
        "content": "## ⚙️ 初始设置"
      },
      "typeVersion": 1
    },
    {
      "id": "b0c352e7-4f9e-4290-9b34-e5603423143f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 336,
        "content": "## 📊 数据源"
      },
      "typeVersion": 1
    },
    {
      "id": "1a464427-aed0-4d9e-9176-2728d947bad7",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 352,
        "content": "## 🌐 API 详情"
      },
      "typeVersion": 1
    },
    {
      "id": "8f07398e-256f-4e33-9972-9786519a37e1",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 288,
        "content": "## 📱 通知"
      },
      "typeVersion": 1
    },
    {
      "id": "82a3945d-fac6-4ff5-820a-f3d6aacbc31e",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 352,
        "content": "## 📄 插入新数据"
      },
      "typeVersion": 1
    },
    {
      "id": "3de014ac-1ab2-483e-90bb-fda01fdbf431",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -528
      ],
      "parameters": {
        "width": 272,
        "height": 112,
        "content": "# 📌 关注我:"
      },
      "typeVersion": 1
    },
    {
      "id": "36960786-d9cd-4527-957d-4762b2131aa7",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -400
      ],
      "parameters": {
        "width": 640,
        "height": 368,
        "content": "# 📋 工作流工作原理"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "71a2befa-8a16-419d-b2cf-750ef55a4ab2",
  "connections": {
    "Settings": {
      "main": [
        [
          {
            "node": "Get All CNPJs in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop CNPJs": {
      "main": [
        [
          {
            "node": "Limit Notifier Interactions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send API Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send API Request": {
      "main": [
        [
          {
            "node": "Update CNPJ Info in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All CNPJs in Sheet": {
      "main": [
        [
          {
            "node": "Loop CNPJs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Manually": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update CNPJ Info in Sheet": {
      "main": [
        [
          {
            "node": "Loop CNPJs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit Notifier Interactions": {
      "main": [
        [
          {
            "node": "Notify When Finish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 潜在客户开发, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量15
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Vitorio Magalhães

Vitorio Magalhães

@vikthyr

Brazilian Full Stack Developer passionate about making automation accessible to everyone. I create free n8n workflows that solve real problems - from NASA space content to marketing automation. Proving that powerful automation doesn't need to be expensive or complicated. Teaching through templates, one node at a time.

外部链接
在 n8n.io 查看

分享此工作流