This workflow follows the Emailsend → 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 →
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
160,
0
],
"id": "65746de7-2cdd-470d-b84d-5eb87b8bb67e",
"name": "Fim"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "1cbf1ce8-09fa-49e7-9e2e-298d2034153c",
"leftValue": "={{ $json.Importado }}",
"rightValue": "N\u00e3o",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
576,
224
],
"id": "ad7db8da-fc5c-4165-8d4f-ff709d930f2f",
"name": "Se"
},
{
"parameters": {
"method": "POST",
"url": "https://api.arquivei.com.br/v2/dfe/nfe",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "X-API-ID",
"value": ""
},
{
"name": "X-API-KEY",
"value": ""
},
{
"name": "X-Use-ApiGateway",
"value": "always"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"fields\": [\n \"Xml\",\n \"Origin\",\n \"FlagErp\",\n \"Document\",\n \"Events\",\n \"Tags\",\n \"Cfops\",\n \"AccessKey\",\n \"EmissionDate\",\n \"CreatedAt\",\n \"HasCCE\",\n \"Manifestations\",\n \"Number\",\n \"Owner\",\n \"OwnerRole\",\n \"Receiver\",\n \"Emitter\",\n \"Status\"\n ],\n \"Filters\": {\n \"EmissionDate\": {\n \"From\": \"{{ $now.minus({days: 0}).startOf('day').toFormat('yyyy-MM-dd HH:mm:ss') }}\",\n \"To\": \"{{ $now.endOf('day').toFormat('yyyy-MM-dd HH:mm:ss') }}\"\n },\n \"ReceiverCnpj\": [\n \"07150434000117\"\n ]\n },\n \"paginator\": \"\"\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
-544,
112
],
"id": "930f37b4-5d39-42b0-9c93-a6990c9c77da",
"name": "Busca as XMLs"
},
{
"parameters": {
"fieldToSplitOut": "Nfes",
"options": {}
},
"type": "n8n-nodes-base.itemLists",
"typeVersion": 3,
"position": [
-336,
112
],
"id": "a2d808c9-5c71-4b06-834c-2880c2d85ffd",
"name": "Organiza as XMLs"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
-128,
112
],
"id": "5df752b9-2210-4a64-8cc1-5e0df5400915",
"name": "Para cada XML"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "17eac68c-2fc3-4787-8170-3d8f8b8eb64e",
"name": "companyId",
"value": "={{ $('Consulta as informa\u00e7\u00f5es das empresas').item.json.companyId }}",
"type": "number"
},
{
"id": "c5c061c0-25f1-486d-89f1-de163218e8d4",
"name": "customerVendorCode",
"value": "={{ $('Consulta as informa\u00e7\u00f5es das empresas').item.json.customerVendorCode }}",
"type": "string"
},
{
"id": "4733edeb-911d-4881-a0c8-f4637981ad86",
"name": "productId",
"value": "={{ $('Consulta as informa\u00e7\u00f5es das empresas').item.json.productId }}",
"type": "number"
},
{
"id": "63cd8328-a359-4b0a-8c3f-da29cea37650",
"name": "NFeAccesskey",
"value": "={{ $('Para cada XML').item.json.AccessKey }}",
"type": "string"
},
{
"id": "8eb08e98-88f3-4509-accc-f00290cab4ab",
"name": "number",
"value": "={{ $('Para cada XML').item.json.Number.padStart(9, '0') }}",
"type": "string"
},
{
"id": "477c41c8-effa-4cba-8aba-def4c8897d44",
"name": "series",
"value": "={{ $('Para cada XML').item.json.Document.Ide.Serie }}",
"type": "string"
},
{
"id": "7cd7cdef-9335-40e4-8002-5e5aae0a2610",
"name": "RegisterDate",
"value": "={{ $('Para cada XML').item.json.EmissionDate }}",
"type": "string"
},
{
"id": "356d0393-8b55-4298-951e-102edc39d7c3",
"name": "unitPrice",
"value": "={{ $('Para cada XML').item.json.Document.Total.ICMSTot.VNF }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1904,
-112
],
"id": "af1ae5a0-f6f7-41ca-95e0-942e31888510",
"name": "Padroniza os dados"
},
{
"parameters": {
"language": "pythonNative",
"pythonCode": "companyId = str(_items[0][\"json\"][\"companyId\"])\nNFeAccesskey = str(_items[0][\"json\"][\"NFeAccesskey\"])\nnumber = str(_items[0][\"json\"][\"number\"])\nseries = str(_items[0][\"json\"][\"series\"])\ncustomerVendorCode = str(_items[0][\"json\"][\"customerVendorCode\"])\nRegisterDate = str(_items[0][\"json\"][\"RegisterDate\"])\nproductId = int(_items[0][\"json\"][\"productId\"])\nunitPrice = float(_items[0][\"json\"][\"unitPrice\"])\n\npayload = {\n \"aplicationIntegration\": \"T\",\n \"internalId\": f\"{companyId}|99999999\",\n \"companyId\": companyId,\n \"movementId\": 99999999,\n \"branchId\": 1,\n \"movementTypeCode\": \"1.2.02\",\n \"NFeAccesskey\": NFeAccesskey,\n \"number\": number,\n \"series\": series,\n \"customerVendorCompanyId\": companyId,\n \"customerVendorCode\": customerVendorCode,\n \"RegisterDate\": RegisterDate,\n \"observation\": \"Movimento Importado Via Automa\u00e7\u00e3o\",\n \"movementItems\": [\n {\n \"aplicationIntegration\": \"T\", \n \"companyId\": companyId,\n \"branchId\": 1, \n \"movementId\": 99999999,\n \"warehouseCode\": \"01.001\",\n \"sequentialId\": 1,\n \"sequentialNumber\": 1,\n \"productId\": productId,\n \"quantity\": 1.0,\n \"unitPrice\": unitPrice\n }\n ]\n}\n\nreturn [{\"json\": {\"body\": payload}}]"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2112,
-112
],
"id": "f1ab53c3-3322-447e-9255-f41e13c96bd3",
"name": "Preenche o payload"
},
{
"parameters": {
"method": "POST",
"url": "http://apptotvs.sinasc.com.br:8051/api/mov/v1/Movements",
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ $json.body }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
2320,
-112
],
"id": "26703203-2975-4fa6-a41a-6ab5b8443d69",
"name": "Registra o movimento",
"credentials": {
"httpBasicAuth": {
"name": "<your credential>"
}
},
"onError": "continueErrorOutput"
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 30
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
-752,
112
],
"id": "7c545faa-925e-4245-861e-64d05471160e",
"name": "Cron\u00f4metro"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n CASE \n WHEN EXISTS (SELECT 1 FROM TMOV WHERE CODCOLIGADA = '{{ $json.companyId }}' AND CODTMV = '1.2.02' AND CHAVEACESSONFE = '{{ $('Para cada XML').item.json.AccessKey }}') THEN 'Sim'\n ELSE 'N\u00e3o'\n END AS Importado",
"options": {}
},
"type": "n8n-nodes-base.microsoftSql",
"typeVersion": 1.1,
"position": [
368,
224
],
"id": "63b6f9f9-df9d-4a36-9996-21e66d56f4eb",
"name": "Consulta se j\u00e1 foi importado",
"alwaysOutputData": false,
"credentials": {
"microsoftSql": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"fromEmail": "gabriel.souza@gruposmi.com.br",
"toEmail": "tecnologia@gruposmi.com.br",
"subject": "=Erro ao importar nota de dispesa",
"emailFormat": "html",
"html": "=<p>Erro ao importar a nota {{ $json.body.NFeAccesskey }} da coligada {{ $json.body.companyId }}</p>\n\n<p>Informa\u00e7\u00f5es do Erro:</p>\n<pre style=\"background-color: #1e1e1e; color: #ffffff; padding: 15px; border-radius: 6px; font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 1.5; overflow-x: auto;\"><code>{{ (() => { \n try { \n const clean = $json.error.message.replace(/^\\d{3} - /, ''); \n return JSON.stringify(JSON.parse(JSON.parse(clean)), null, 2); \n } catch (e) { \n return $json.error.message; \n } \n})() }}</code></pre>",
"options": {}
},
"id": "9abfd13f-9d65-4530-bd4e-605e5da94511",
"name": "Envia um email de aviso",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
2624,
0
],
"credentials": {
"smtp": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n\tGCOLIGADA.CODCOLIGADA AS companyId, \n\tFCFO.CODCFO AS customerVendorCode,\n\tCASE\n\t\tWHEN GCOLIGADA.CODCOLIGADA = 1 THEN 135195\n\t\tWHEN GCOLIGADA.CODCOLIGADA = 5 THEN 135132\n\t\tWHEN GCOLIGADA.CODCOLIGADA = 6 THEN 135196\n\t\tELSE NULL\n\tEND AS productId\n\nFROM GCOLIGADA (NOLOCK)\n\tLEFT JOIN FCFO (NOLOCK) ON (\n\t\tFCFO.CODCOLIGADA = GCOLIGADA.CODCOLIGADA AND\n\t\tFCFO.CGCCFO = '{{ $json.Document.Emit.CNPJ.replace(/^(\\d{2})(\\d{3})(\\d{3})(\\d{4})(\\d{2})/, '$1.$2.$3/$4-$5') }}'\n\t)\n\nWHERE 1=1\n\tAND GCOLIGADA.CGC = '{{ $json.Document.Dest.CNPJ.replace(/^(\\d{2})(\\d{3})(\\d{3})(\\d{4})(\\d{2})/, '$1.$2.$3/$4-$5') }}'\n",
"options": {}
},
"type": "n8n-nodes-base.microsoftSql",
"typeVersion": 1.1,
"position": [
160,
224
],
"id": "e073ea07-2900-4ec4-b28b-a1876c7674e7",
"name": "Consulta as informa\u00e7\u00f5es das empresas",
"alwaysOutputData": false,
"credentials": {
"microsoftSql": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "1cbf1ce8-09fa-49e7-9e2e-298d2034153c",
"leftValue": "={{ $json.Dispesa }}",
"rightValue": "Sim",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
1600,
0
],
"id": "1ea474d2-64d9-42ef-a0cc-703581a71646",
"name": "Se 2"
},
{
"parameters": {
"language": "pythonNative",
"pythonCode": "result = []\n\nfor item in _items:\n cnaes = []\n \n json_data = item.get(\"json\", {}).get(\"data\", {})\n \n atv_principal = json_data.get(\"atividade_principal\") or []\n for atv in atv_principal:\n if atv and isinstance(atv, dict):\n code = atv.get(\"code\", \"\")\n if code:\n cnaes.append(code)\n \n atv_secundarias = json_data.get(\"atividades_secundarias\") or []\n for atv in atv_secundarias:\n if atv and isinstance(atv, dict):\n code = atv.get(\"code\", \"\")\n if code:\n cnaes.append(code)\n\n cnaes = list(set(cnaes))\n cnaes_for_query = \"'\" + \"', '\".join(cnaes) + \"'\" if cnaes else \"''\"\n \n result.append({\n \"json\": {\n \"cnaes\": cnaes_for_query\n }\n })\n\nreturn result"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1184,
0
],
"id": "66b98dcd-2a7d-49c7-a1a0-0d9713ac3b9f",
"name": "Formata os cnaes"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n CASE \n WHEN EXISTS (SELECT 1 FROM ZCNAES WHERE CNAE IN ({{ $json.cnaes }}) AND DISPESA = 1) THEN 'Sim'\n ELSE 'N\u00e3o'\n END AS Dispesa",
"options": {}
},
"type": "n8n-nodes-base.microsoftSql",
"typeVersion": 1.1,
"position": [
1392,
0
],
"id": "56173f96-0216-4286-a7a2-53d668aad567",
"name": "Valida os cnaes",
"credentials": {
"microsoftSql": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"url": "=https://api.arquivei.com.br/v1/cnpj/{{ $('Para cada XML').item.json.Document.Emit.CNPJ }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "X-API-ID",
"value": ""
},
{
"name": "X-API-KEY",
"value": ""
},
{
"name": "X-Use-ApiGateway",
"value": "always"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
880,
112
],
"id": "f9213872-f4ea-4dc7-b4eb-c33049995d4c",
"name": "Consulta os cnaes",
"onError": "continueErrorOutput"
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE TNFEENTRADA SET IDMOV = '{{ $json.movementId }}' WHERE CODCOLIGADA = '{{ $json.companyId }}' AND CHAVEACESSO = '{{ $json.nFeAccesskey }}'",
"options": {}
},
"type": "n8n-nodes-base.microsoftSql",
"typeVersion": 1.1,
"position": [
2624,
-224
],
"id": "1cf09768-468b-4084-a2e0-0e859a8949d8",
"name": "Vincula o Movimento ao XML",
"credentials": {
"microsoftSql": {
"name": "<your credential>"
}
}
}
],
"connections": {
"Se": {
"main": [
[
{
"node": "Consulta os cnaes",
"type": "main",
"index": 0
}
],
[
{
"node": "Para cada XML",
"type": "main",
"index": 0
}
]
]
},
"Busca as XMLs": {
"main": [
[
{
"node": "Organiza as XMLs",
"type": "main",
"index": 0
}
]
]
},
"Organiza as XMLs": {
"main": [
[
{
"node": "Para cada XML",
"type": "main",
"index": 0
}
]
]
},
"Para cada XML": {
"main": [
[
{
"node": "Fim",
"type": "main",
"index": 0
}
],
[
{
"node": "Consulta as informa\u00e7\u00f5es das empresas",
"type": "main",
"index": 0
}
]
]
},
"Padroniza os dados": {
"main": [
[
{
"node": "Preenche o payload",
"type": "main",
"index": 0
}
]
]
},
"Preenche o payload": {
"main": [
[
{
"node": "Registra o movimento",
"type": "main",
"index": 0
}
]
]
},
"Registra o movimento": {
"main": [
[
{
"node": "Vincula o Movimento ao XML",
"type": "main",
"index": 0
}
],
[
{
"node": "Envia um email de aviso",
"type": "main",
"index": 0
}
]
]
},
"Cron\u00f4metro": {
"main": [
[
{
"node": "Busca as XMLs",
"type": "main",
"index": 0
}
]
]
},
"Consulta se j\u00e1 foi importado": {
"main": [
[
{
"node": "Se",
"type": "main",
"index": 0
}
]
]
},
"Envia um email de aviso": {
"main": [
[
{
"node": "Para cada XML",
"type": "main",
"index": 0
}
]
]
},
"Consulta as informa\u00e7\u00f5es das empresas": {
"main": [
[
{
"node": "Consulta se j\u00e1 foi importado",
"type": "main",
"index": 0
}
]
]
},
"Se 2": {
"main": [
[
{
"node": "Padroniza os dados",
"type": "main",
"index": 0
}
],
[
{
"node": "Para cada XML",
"type": "main",
"index": 0
}
]
]
},
"Formata os cnaes": {
"main": [
[
{
"node": "Valida os cnaes",
"type": "main",
"index": 0
}
]
]
},
"Valida os cnaes": {
"main": [
[
{
"node": "Se 2",
"type": "main",
"index": 0
}
]
]
},
"Consulta os cnaes": {
"main": [
[
{
"node": "Formata os cnaes",
"type": "main",
"index": 0
}
],
[
{
"node": "Envia um email de aviso",
"type": "main",
"index": 0
}
]
]
},
"Vincula o Movimento ao XML": {
"main": [
[
{
"node": "Para cada XML",
"type": "main",
"index": 0
}
]
]
}
},
"meta": {
"templateCredsSetupCompleted": true
}
}
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.
httpBasicAuthmicrosoftSqlsmtp
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Importacao-Notas-Dispesas. Uses httpRequest, itemLists, microsoftSql, emailSend. Scheduled trigger; 17 nodes.
Source: https://github.com/gabriel-pagani/n8n-self-hosted/blob/0230a3df5b831e08726b51d054e0e785a89b8f9b/workflows/importacao-notas-dispesas.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.
VHS - ROE Auto Update (Daily Forex Sync, Tenant-Aware). Uses microsoftSql, httpRequest, emailSend. Scheduled trigger; 21 nodes.
This workflow automates the full cycle of fetching, processing, and storing Telr payment gateway reports — and then notifying your team by email. It runs on a schedule, calls the Telr API twice (once
Birthday Automation - Production (Fixed). Uses stopAndError, httpRequest, emailSend, bannerbear. Scheduled trigger; 86 nodes.
This workflow is an improvement of this workflow by Greg Brzezinka.
N8N-Self-Updater. Uses ssh, emailSend, httpRequest. Scheduled trigger; 27 nodes.