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": "CMM",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "gosac",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-5240,
520
],
"id": "2d42e5a6-4916-4997-bf9e-f01ad0f32f1d",
"name": "Webhook1"
},
{
"parameters": {
"jsCode": "// Data fornecida no item\nconst inputDate = new Date($('Analisar ticket').first().json.lastmessage); // exemplo: \"2025-04-30T14:24:34.830Z\"\n\n// Pega a hora atual de Manaus (UTC-4)\nconst now = new Date();\nconst nowManaus = new Date(now.getTime()); // ajuste real de fuso pode ser adicionado se necess\u00e1rio\n\n// Calcula diferen\u00e7a em milissegundos\nconst diffMs = Math.abs(nowManaus - inputDate);\nconst diffMinutes = diffMs / (1000 * 60);\n\n// Retorna resultado com detalhes\nreturn [\n {\n json: {\n inputDate: inputDate.toISOString(),\n currentDateManaus: nowManaus.toISOString(),\n differenceInMinutes: diffMinutes,\n passedOneHour: diffMinutes > 60\n }\n }\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-2480,
820
],
"id": "a216d673-e3b4-4c0d-9bdc-6c216e0b962e",
"name": "Comparar tempo",
"executeOnce": true,
"onError": "continueRegularOutput"
},
{
"parameters": {
"url": "=https://cmmodulados.gosac.com.br/api/tickets/{{ $('Coleta de dados').first().json.ticketId }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "INTEGRATION 0ddfe6600ac270ae602f509c3bf247dd8b581fe6672dc48fcb2853d91328"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
400,
260
],
"id": "e2d0b284-620f-4354-86c5-9fb33d0f1167",
"name": "Recuperar ticket",
"alwaysOutputData": false,
"retryOnFail": false,
"onError": "continueErrorOutput"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "54d6dd2c-f996-4728-bc33-706bfb5fd50b",
"leftValue": "={{ $('Analisar ticket').first().json.ematendimento }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-2760,
800
],
"id": "f0ddad35-7f1b-4b4b-aeb7-119a9e9ee73d",
"name": "Se o cliente est\u00e1 em atendimento pessoal",
"executeOnce": true
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "54d6dd2c-f996-4728-bc33-706bfb5fd50b",
"leftValue": "={{ $('Analisar ticket').first().json.ticketid }}",
"rightValue": "={{ $('Webhook1').first().json.body.data.ticketId }}",
"operator": {
"type": "number",
"operation": "notEquals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-3000,
600
],
"id": "a4f359eb-bbf5-4692-a07b-9c855615f830",
"name": "Se o atendimento do cliente est\u00e1 fechado"
},
{
"parameters": {
"method": "POST",
"url": "=https://cmmodulados.gosac.com.br/api/messages/{{ $('Coleta de dados').first().json.ticketId }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "INTEGRATION 1f7e1c970adf60b4ac6dc56afbc4edcd3ed52de8656fb38f7e899bff6889"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"body\": \"\u23f3 Como houve uma pausa no atendimento, vamos reiniciar o processo para garantir que tudo ocorra da melhor forma poss\u00edvel. \ud83d\ude0a\\n\\n\ud83d\udccb Fique tranquilo(a), vamos retomar desde o in\u00edcio para garantir que nenhuma informa\u00e7\u00e3o importante seja perdida!\"\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-2300,
580
],
"id": "5418d4ac-81ae-4736-8b61-684b780e5f9a",
"name": "Encaminhar template de desencontro",
"alwaysOutputData": false
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "0f1a269f-be96-497c-9606-8215f980e040",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "hsm",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "1a8d3515-5927-4cf6-a8de-edace2416d28",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "transfer",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "7cecf1ad-e84e-4d06-bf9d-e2a1978660f1",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "ptt",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "30f0ae48-2399-4ed8-a308-fa5caeaf3637",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "sticker",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "1e7ad166-f80c-4487-8eef-2b9890632152",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "vcard",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "e75fc81a-7035-4484-98a9-3515af924f38",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "location",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "bc4d4162-3e68-41fe-a149-c57bfb026a8a",
"leftValue": "={{ $json.body.data.mediaType }}",
"rightValue": "impostor",
"operator": {
"type": "string",
"operation": "notEquals"
}
},
{
"id": "e7ce0230-5f3b-4d92-801c-1f729f3d0479",
"leftValue": "={{ $json.body.data.fromMe }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
}
},
{
"id": "48bf0bf9-e09f-4b72-8c80-40c1c984ae2b",
"leftValue": "={{ $json.body.data.ticket.contact.isGroup }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-5060,
520
],
"id": "a2e1b967-1c29-41c6-96d1-231829b06280",
"name": "Se a mensagem n\u00e3o for um hsm ou um transfer"
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tb_mensagem_cliente",
"mode": "list",
"cachedResultName": "tb_mensagem_cliente"
},
"where": {
"values": [
{
"column": "contactid",
"value": "={{ $('Webhook1').first().json.body.data.contactId }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-3720,
500
],
"id": "58351ef1-44a6-41a1-afb0-840f9232eae7",
"name": "Analisar ticket",
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tb_mensagem_cliente",
"mode": "list",
"cachedResultName": "tb_mensagem_cliente"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"contactid": "={{ $json.contactId }}",
"lastmessage": "={{ $json.updatedAt }}"
},
"matchingColumns": [
"contactid"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediapath",
"displayName": "mediapath",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "body",
"displayName": "body",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediatype",
"displayName": "mediatype",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ticketid",
"displayName": "ticketid",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "contactid",
"displayName": "contactid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "userid",
"displayName": "userid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessageat",
"displayName": "lastmessageat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "nome",
"displayName": "nome",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ematendimento",
"displayName": "ematendimento",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "finalizoutriagem",
"displayName": "finalizoutriagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "stopchatbot",
"displayName": "stopchatbot",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "templateid",
"displayName": "templateid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "pararmensagem",
"displayName": "pararmensagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessage",
"displayName": "lastmessage",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "state",
"displayName": "state",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "fase_arquivos",
"displayName": "fase_arquivos",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
660,
240
],
"id": "b23cd958-e9e8-428b-9402-88d71bd20337",
"name": "Atualizar data da ultima mensagem",
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tb_mensagem_cliente",
"mode": "list",
"cachedResultName": "tb_mensagem_cliente"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"contactid": "={{ $('Webhook1').first().json.body.data.contactId }}",
"ticketid": "={{ $('Webhook1').first().json.body.data.ticketId }}",
"state": 1,
"fase_arquivos": "projeto"
},
"matchingColumns": [
"contactid"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediapath",
"displayName": "mediapath",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "body",
"displayName": "body",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediatype",
"displayName": "mediatype",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ticketid",
"displayName": "ticketid",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "contactid",
"displayName": "contactid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "userid",
"displayName": "userid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessageat",
"displayName": "lastmessageat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "nome",
"displayName": "nome",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ematendimento",
"displayName": "ematendimento",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "finalizoutriagem",
"displayName": "finalizoutriagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "stopchatbot",
"displayName": "stopchatbot",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "templateid",
"displayName": "templateid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "pararmensagem",
"displayName": "pararmensagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessage",
"displayName": "lastmessage",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "state",
"displayName": "state",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "fase_arquivos",
"displayName": "fase_arquivos",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "local_arquivo",
"displayName": "local_arquivo",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "id_atendente",
"displayName": "id_atendente",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "data_medicao",
"displayName": "data_medicao",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-2100,
580
],
"id": "efd25dd4-1941-428a-8595-e10bdf9d4da1",
"name": "Reiniciar chatbot",
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "set",
"key": "=chatbot:last:user:{{ $('Webhook1').item.json.body.data.contactId }}",
"value": "={{ $('Webhook1').item.json.body.data.body }}"
},
"type": "n8n-nodes-base.redis",
"typeVersion": 1,
"position": [
-4660,
520
],
"id": "0bbfbaf8-5b2b-4b14-9b9d-6addd3f2aff8",
"name": "Armazenar primeira mensagem",
"credentials": {
"redis": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "get",
"propertyName": "body",
"key": "=chatbot:last:user:{{ $('Webhook1').item.json.body.data.contactId }}",
"options": {}
},
"type": "n8n-nodes-base.redis",
"typeVersion": 1,
"position": [
-4340,
520
],
"id": "b18d888b-b5bb-4d1f-a0e1-8302c8a58ffe",
"name": "Buscar ultima mensagem",
"credentials": {
"redis": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"amount": 3
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
-4500,
520
],
"id": "61a7c69d-e0dd-4a74-befa-435ba4a89235",
"name": "Debounce"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "ee456ab8-0868-43be-b359-cee7c5c2a428",
"leftValue": "={{ $json.body === $('Webhook1').first().json.body.data.body }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"looseTypeValidation": "={{ false }}",
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-4120,
500
],
"id": "6566c763-b278-4d2e-a2e9-64044a2b0214",
"name": "\u00c9 a mesma mensagem?"
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "80bae584-92ba-4cee-b579-5ac8deff4113",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 1,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "342702ea-d707-4726-8e79-9e0652641ffa",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 2,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "b190979d-cd3d-4ece-b93f-760eb7775503",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 3,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "73d997e5-602a-4461-b90d-7ad93f1b2649",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 4,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "dbc521e6-fad4-489d-9711-99bebc750112",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 5,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "e85de774-ac44-477d-bce2-73b78c0627ca",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 6,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "132b97c3-a605-402f-865a-3f156c644f7e",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 7,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "8d4f585b-280d-4144-ba8c-0eac11859d7a",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 8,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c8945009-cf5a-487f-b588-1d9ab9ad0b54",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 9,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "a5aa9715-c7e8-4d7d-81cc-583b17f1c1e7",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 10,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "e7035ca2-deb9-4364-9033-447eb903dd7b",
"leftValue": "={{ $('Analisar ticket').first().json.state }}",
"rightValue": 11,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
}
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-1820,
300
],
"id": "8a0c3d1f-dbf3-4b05-89dc-5ca9d01761bd",
"name": "Se o estado do cliente",
"executeOnce": true
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"leftValue": "={{ $('Coleta de dados').first().json.body }}",
"rightValue": "1",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "913b8fa1-2f06-4824-b9e6-81e9df33d889"
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "62b4298b-e079-4f2d-9264-a67c8e7c8e7a",
"leftValue": "={{ $('Coleta de dados').first().json.body }}",
"rightValue": "2",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
}
],
"combinator": "and"
}
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-580,
-400
],
"id": "25e39541-b2cb-445e-8c5a-85e582fa3242",
"name": "Tem ou nao projeto"
},
{
"parameters": {
"method": "POST",
"url": "=https://cmmodulados.gosac.com.br/api/messages/{{ $('Coleta de dados').first().json.ticketId }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "INTEGRATION 1f7e1c970adf60b4ac6dc56afbc4edcd3ed52de8656fb38f7e899bff6889"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"body\": \"\ud83d\udcc2 Perfeito! Isso vai agilizar bastante o nosso processo.\\nVoc\u00ea pode me enviar os arquivos do seu projeto, como:\\n\\n\ud83d\udcc4 Planta baixa\\n\ud83d\uddbc\ufe0f Imagens\\n\ud83d\udcd1 Outros documentos que ajudem nossa equipe a entender melhor o espa\u00e7o.\\n\\nAssim, conseguimos preparar um or\u00e7amento ainda mais preciso pra voc\u00ea!\\n\\nQuando finalizar o envio mande um \\\"OK\\\" \ud83d\ude0a\"\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-60,
-480
],
"id": "64a9b11d-70bc-45ee-9790-5e44192fee1a",
"name": "Enviar template do Tenho Projeto",
"alwaysOutputData": false
},
{
"parameters": {
"operation": "update",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tb_mensagem_cliente",
"mode": "list",
"cachedResultName": "tb_mensagem_cliente"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"contactid": "={{ $('Coleta de dados').first().json.contactId }}",
"state": 4,
"fase_arquivos": "projeto"
},
"matchingColumns": [
"contactid"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediapath",
"displayName": "mediapath",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "body",
"displayName": "body",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediatype",
"displayName": "mediatype",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ticketid",
"displayName": "ticketid",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "contactid",
"displayName": "contactid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "userid",
"displayName": "userid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessageat",
"displayName": "lastmessageat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "nome",
"displayName": "nome",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ematendimento",
"displayName": "ematendimento",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "finalizoutriagem",
"displayName": "finalizoutriagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "stopchatbot",
"displayName": "stopchatbot",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "templateid",
"displayName": "templateid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "pararmensagem",
"displayName": "pararmensagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessage",
"displayName": "lastmessage",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "state",
"displayName": "state",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "fase_arquivos",
"displayName": "fase_arquivos",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "local_arquivo",
"displayName": "local_arquivo",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "id_atendente",
"displayName": "id_atendente",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "data_medicao",
"displayName": "data_medicao",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
180,
-480
],
"id": "e882161a-5878-4a60-af71-72a2595afde4",
"name": "Atualizar estado Tenho Projeto",
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"method": "POST",
"url": "=https://cmmodulados.gosac.com.br/api/messages/{{ $('Coleta de dados').first().json.ticketId }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "INTEGRATION 1f7e1c970adf60b4ac6dc56afbc4edcd3ed52de8656fb38f7e899bff6889"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"body\": \"\ud83d\udccf Sem problemas, a gente te ajuda desde o comecinho!\\nVoc\u00ea tem as medidas do ambiente ou uma planta baixa simples com as dimens\u00f5es? J\u00e1 \u00e9 o suficiente pra come\u00e7armos a montar algo para voc\u00ea. \ud83d\ude04\\n\\n1 - Tenho as medidas \ud83d\udcd0\\n2 - N\u00e3o tenho as medidas \u274c\"\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-60,
-300
],
"id": "1d0f6465-45ef-46b4-898e-a960ac116f51",
"name": "Enviar template da Planta Baixa",
"alwaysOutputData": false
},
{
"parameters": {
"operation": "update",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tb_mensagem_cliente",
"mode": "list",
"cachedResultName": "tb_mensagem_cliente"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"contactid": "={{ $('Coleta de dados').first().json.contactId }}",
"state": 5,
"fase_arquivos": "plantabaixa"
},
"matchingColumns": [
"contactid"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediapath",
"displayName": "mediapath",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "body",
"displayName": "body",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediatype",
"displayName": "mediatype",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ticketid",
"displayName": "ticketid",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "contactid",
"displayName": "contactid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "userid",
"displayName": "userid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessageat",
"displayName": "lastmessageat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "nome",
"displayName": "nome",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "ematendimento",
"displayName": "ematendimento",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "finalizoutriagem",
"displayName": "finalizoutriagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "stopchatbot",
"displayName": "stopchatbot",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "templateid",
"displayName": "templateid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "pararmensagem",
"displayName": "pararmensagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "lastmessage",
"displayName": "lastmessage",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "state",
"displayName": "state",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "fase_arquivos",
"displayName": "fase_arquivos",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "local_arquivo",
"displayName": "local_arquivo",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "id_atendente",
"displayName": "id_atendente",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "data_medicao",
"displayName": "data_medicao",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
180,
-300
],
"id": "4314072f-baa0-45ac-b88c-1f37f2c0e41c",
"name": "Atualizar estado Planta Baixa",
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "673560ca-5ed7-431a-b36b-a792d81e68c6",
"leftValue": "={{ $('Coleta de dados').first().json.mediaUrl }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"leftValue": "={{ $('Coleta de dados').first().json.body }}",
"rightValue": "OK",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "0d578425-cf4b-48d2-aac1-321130273d3a"
}
],
"combinator": "and"
}
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-660,
-100
],
"id": "236e49d8-f1f1-4188-a0ce-f8a90acd485a",
"name": "Finalizou o envio dos arquivos?"
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"leftValue": "={{ $('Coleta de dados').first().json.body }}",
"rightValue": "1",
"operator": {
"type": "string",
"operation": "equals"
},
"id": "05fb400e-d317-4619-b061-5807ed8dd92d"
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "599df145-8af3-48f7-a147-7bf743ddd749",
"leftValue": "={{ $('Coleta de dados').first().json.body }}",
"rightValue": "2",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
}
],
"combinator": "and"
}
}
]
},
"options": {}
},
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-340,
560
],
"id": "af09afdf-f4df-414b-86a6-bc17e00081fb",
"name": "Tem ou n\u00e3o planta baixa??"
},
{
"parameters": {
"method": "POST",
"url": "=https://cmmodulados.gosac.com.br/api/messages/{{ $('Coleta de dados').first().json.ticketId }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "INTEGRATION 1f7e1c970adf60b4ac6dc56afbc4edcd3ed52de8656fb38f7e899bff6889"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"body\": \"\ud83d\udcc4 Perfeito!\\nCom as medidas da planta baixa em m\u00e3os, vamos poder avan\u00e7ar para criar um or\u00e7amento bem detalhado e personalizado para voc\u00ea. Agora precisamos que envie o documento com as medidas.\\n\\n\ud83d\udce4 Voc\u00ea pode enviar por aqui mesmo.\\n\\nQuando finalizar o envio mande um \\\"OK\\\"\"\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-40,
480
],
"id": "afac38f7-20be-4653-b364-b22eb162331e",
"name": "Enviar template Tem Planta Baixa",
"alwaysOutputData": false
},
{
"parameters": {
"operation": "update",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tb_mensagem_cliente",
"mode": "list",
"cachedResultName": "tb_mensagem_cliente"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"contactid": "={{ $('Coleta de dados').first().json.contactId }}",
"state": 4,
"fase_arquivos": "plantabaixa"
},
"matchingColumns": [
"contactid"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "mediapath",
"displayName": "mediapath",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "body",
"displayName": "body",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
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.
postgresredis
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
CMM. Uses httpRequest, postgres, redis. Webhook trigger; 90 nodes.
Source: https://github.com/moisesoliveira-dev/chatbot-cmm/blob/41f0039d7851470c414235ddd7dd10b7a8dbe2a3/CMM.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.
Wm-Admin.N8N-Import. Uses postgres, httpRequest, redis. Webhook trigger; 12 nodes.
Reagendamiento_v2. Uses executeWorkflowTrigger, redis, httpRequest, n8n-nodes-evolution-api. Event-driven trigger; 89 nodes.
This solution enables you to manage all your Notion and Todoist tasks from different workspaces as well as your calendar events in a single place. This is 2 way sync with partial support for recurring
Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.
Agendamiento_v2. Uses n8n-nodes-evolution-api, redis, httpRequest, executeWorkflowTrigger. Event-driven trigger; 59 nodes.