{
  "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",
              "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": [
        160,
        480
      ],
      "id": "f8f55d54-9af1-4a40-8a19-43ddba21f4f9",
      "name": "Atualizar estado Tenho Planta Baixa",
      "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": "={{ $('Coleta de dados').first().json.contactId }}",
            "state": 7
          },
          "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": true
            },
            {
              "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,
        260
      ],
      "id": "efb9558d-4aa2-4264-b81d-e4fc34807b23",
      "name": "Atualizar estado Ambientes",
      "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\udccc Para que possamos te ajudar da melhor forma, por favor, siga os passos abaixo:\\n\\n1\u00ba Acesse o site da construtora ou do condom\u00ednio respons\u00e1vel pelo seu im\u00f3vel.\\n2\u00ba Procure pela planta baixa do seu apartamento.\\n3\u00ba Tire um print (captura de tela) ou baixe a imagem da planta.\\n4\u00ba Envie a imagem aqui mesmo por esta conversa.\ud83d\udce4\\n\\n\ud83d\udd0e Selecione uma das duas op\u00e7\u00f5es para que possamos lhe ajudar da melhor maneira. \ud83d\ude80\\n\\n1 - Achei e enviei a planta baixa.\\n2 - N\u00e3o encontrei a minha planta baixa.\\n\\nLinks de sites que podem ter sua planta baixa:\\n\\n- SKN (Le Gran Ponta Negra): https://sknincorporadora.com.br/empreendimento/le-gran-ponta-negra/#plantas\\n\\n- Colmeia (Vision): https://www.colmeia.com.br/manaus/empreendimento/vision/\\n\\n- Capital (Le Boulevard): https://construtoracapital.com.br/imoveis/place-de-la-concorde-le-boulevard/?gad_source=1&gad_campaignid=22026497650&gbraid=0AAAAApALNojpN77lMkkc3nCUFS80E8199&gclid=Cj0KCQjwoZbBBhDCARIsAOqMEZUDraTs4nsg3kIJAcT0oK8-gQrZukPDa4ajYRJgYv6vTHChonSXjEEaAqJEEALw_wcB\\n\\n- Direcional: https://www.direcional.com.br/encontre-seu-apartamento/\\n\\n- Sensia (La Vie): https://meusensia.com.br/imovel/la-vie/\\n\\n- Riva: https://www.rivaincorporadora.com.br/imoveis?state=Amazonas\\n\\n- MRV: https://www.mrv.com.br/imoveis/amazonas/manaus\\n\\n- MRV (Vista das Paineiras): https://imoveis.mrv.com.br/upload/folder/20220330042115_VISTA-DAS-PAINEIRAS_Apartamentos_MRV_Manaus-AM.pdf\\n\\n- Morar Mais: https://vemmorarmais.com.br/\\n\\n- Mais Lar: https://maislar.com/\"\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -40,
        640
      ],
      "id": "7e2cd85f-cea8-4e25-8d0a-fae53240bb3a",
      "name": "Enviar template N\u00e3o Tem Planta Baixa",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6b58d2b9-9329-41b7-b36b-0ccf9b643751",
              "name": "mediaUrl",
              "value": "={{ $('Webhook1').first().json.body.data.mediaUrl }}",
              "type": "string"
            },
            {
              "id": "c8132fc1-2f9a-410c-9b7f-9625cd498012",
              "name": "mediaPath",
              "value": "={{ $('Webhook1').first().json.body.data.mediaPath }}",
              "type": "string"
            },
            {
              "id": "e4810252-8894-42a5-aa75-49ee26392c0a",
              "name": "body",
              "value": "={{ $('Webhook1').first().json.body.data.body }}",
              "type": "string"
            },
            {
              "id": "5d78d2f5-bed3-4e58-88a1-6c06369eacf7",
              "name": "mediaType",
              "value": "={{ $('Webhook1').first().json.body.data.mediaType }}",
              "type": "string"
            },
            {
              "id": "54a42dcb-24ce-42c3-888b-984d3dc53753",
              "name": "ticketId",
              "value": "={{ $('Webhook1').first().json.body.data.ticketId }}",
              "type": "number"
            },
            {
              "id": "cfda8f33-9590-483f-bd27-dd46d125d8ca",
              "name": "contactId",
              "value": "={{ $('Webhook1').first().json.body.data.contactId }}",
              "type": "number"
            },
            {
              "id": "536af937-2ac4-4e8a-86c5-e78e5ff09653",
              "name": "userId",
              "value": "={{ $('Webhook1').first().json.body.data.ticket.userId }}",
              "type": "number"
            },
            {
              "id": "3f8b2e4c-d394-4d61-af25-8ab21501b72c",
              "name": "number",
              "value": "={{ $('Webhook1').first().json.body.data.contact.number }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3900,
        500
      ],
      "id": "c0b36c16-8d59-45dd-b885-e143d7c38e7a",
      "name": "Coleta de dados"
    },
    {
      "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 }}",
            "fase_arquivos": "plantabaixa",
            "state": 8
          },
          "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": [
        160,
        640
      ],
      "id": "e390cc56-2f80-4d7f-b93f-2aa65f979a77",
      "name": "Atualizar estado N\u00e3o Tenho Planta Baixa",
      "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": "={{ $('Coleta de dados').first().json.contactId }}",
            "state": 9
          },
          "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": true
            },
            {
              "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": [
        840,
        1840
      ],
      "id": "f94683bf-dcf3-4592-8688-4162558d7b78",
      "name": "Atualizar estado Agendamento",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "e7ce0230-5f3b-4d92-801c-1f729f3d0479",
              "leftValue": "={{ $json.body.data.mediaUrl }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -4820,
        500
      ],
      "id": "fa837bcb-57c8-441a-b9ca-ad9e4125f2db",
      "name": "Se for arquivo"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "e7ce0230-5f3b-4d92-801c-1f729f3d0479",
              "leftValue": "={{ $json }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -3200,
        520
      ],
      "id": "91014e6e-ca33-4ad4-9add-23c48ae0bf6d",
      "name": "Cliente novo?"
    },
    {
      "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\udcd0 Ainda n\u00e3o encontrou a planta baixa? Sem problemas!\\n\\nSe preferir, podemos agendar uma visita para realizar as medi\u00e7\u00f5es necess\u00e1rias.\\n\\n\ud83d\udcc5 Deseja agendar um hor\u00e1rio com nossa equipe?\\n\\n1 -  Quero agendar \ud83d\udcdd\\n2 - N\u00e3o quero agendar \u274c\"\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        600,
        1840
      ],
      "id": "abf75e4a-845f-4d96-9153-74bc2f6c3407",
      "name": "Enviar template N\u00e3o achou a planta baixa",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "AYKvd457Vu8dArie",
          "mode": "list",
          "cachedResultName": "Amb. Lead no Driver"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {
          "waitForSubWorkflow": true
        }
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        460,
        -660
      ],
      "id": "8126d1bc-5275-4680-942c-35b394968918",
      "name": "Enviar para cria\u00e7\u00e3o do ambiente do lead",
      "executeOnce": true
    },
    {
      "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 }}",
            "nome": "={{ $('Coleta de dados').first().json.body }}",
            "numero": "={{ $('Coleta de dados').first().json.number }}"
          },
          "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": false
            },
            {
              "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": true
            },
            {
              "id": "fase_arquivos",
              "displayName": "fase_arquivos",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "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
            },
            {
              "id": "numero",
              "displayName": "numero",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -60,
        -660
      ],
      "id": "3a06617f-42db-4be0-bfb4-f1f9eefdb06d",
      "name": "Adicionar nome",
      "alwaysOutputData": true,
      "executeOnce": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "tb_mensagem_cliente",
          "mode": "list",
          "cachedResultName": "tb_mensagem_cliente"
        },
        "where": {
          "values": [
            {
              "column": "contactid",
              "value": "={{ $('Coleta de dados').first().json.contactId }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        160,
        -660
      ],
      "id": "0c407a74-f665-41ad-a605-17c817eea90d",
      "name": "Buscar Cliete Driver",
      "executeOnce": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -300,
        -840
      ],
      "id": "c6816f73-c1d5-4f75-b212-932aef5ccf26",
      "name": "Dados servi\u00e7o"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "njmVImrOZa5TNY7r",
          "mode": "list",
          "cachedResultName": "Projeto"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        180,
        80
      ],
      "id": "aa918533-0978-408d-83ed-4f2d535cbcbd",
      "name": "Entregou projeto",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "TafViUwWa9V3Vw9I",
          "mode": "list",
          "cachedResultName": "Referencias"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        180,
        960
      ],
      "id": "70216364-e947-4834-98d2-357acc3ea2a1",
      "name": "Enviar refer\u00eancias",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "YQ0qt4eyteWmXApN",
          "mode": "list",
          "cachedResultName": "Escolha ambiente"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        180,
        1140
      ],
      "id": "f27635ce-414c-4cdc-b254-547e5be5eb5f",
      "name": "Cliente escolhe ou n\u00e3o o ambiente",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "K3JYvzQkFDZ4Ro9z",
          "mode": "list",
          "cachedResultName": "Armazenar arquivos"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        180,
        -120
      ],
      "id": "6a190a3b-415f-4c79-8f77-acbbcf49bce9",
      "name": "Guardar na pasta do cliente",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "nnhWP942CQlLbFTO",
          "mode": "list",
          "cachedResultName": "Agendamento medi\u00e7\u00e3o"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        220,
        1900
      ],
      "id": "6bda4426-4a91-4f32-a2d4-6ed77bc2ae35",
      "name": "Agendamento de medi\u00e7\u00e3o",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "2JyKz7SwSHpEvtjv",
          "mode": "list",
          "cachedResultName": "Analise de triagem"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        -2560,
        580
      ],
      "id": "74b89ece-4d03-4e9e-b660-7916077cf7df",
      "name": "Estado clente"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -60,
        -120
      ],
      "id": "770c0fd7-8aa5-4dec-bf23-88b40d954357",
      "name": "Dados armazenar arquivos"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -60,
        80
      ],
      "id": "7a860bf0-fe23-431f-86f2-2538bb2d7fd6",
      "name": "Dados entregou o projeto"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -40,
        960
      ],
      "id": "d541b523-bb25-4b33-90ef-1514a8fc2619",
      "name": "Dados servi\u00e7o1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -40,
        1140
      ],
      "id": "d9582e9f-e9ab-462b-b49a-08977ec5ac47",
      "name": "Dados servi\u00e7o2"
    },
    {
      "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\udcdd Para continuarmos, voc\u00ea pode me informar qual ambiente deseja ver e projetar? Mande cada n\u00famero separadamente na mesma mensagem, exemplo: *2 1 3*\\n\\nAs op\u00e7\u00f5es s\u00e3o:\\n\\n1 - \ud83c\udf73 Cozinha\\n2 - \ud83d\udecb\ufe0f Sala de Estar\\n3 - \ud83d\udecf\ufe0f Dormit\u00f3rio\\n4 - \ud83d\udebf Banheiro\\n5 - \ud83c\udf7d\ufe0f Sala de Jantar\\n6 - \ud83c\udf7b Canto Alem\u00e3o\\n7 - \ud83d\udcbb Home Office\\n\\nQuando finalizar o envio mande um \\\"OK\\\"\"\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -60,
        260
      ],
      "id": "ce3c259f-2cdd-4610-aa36-293f25e14c13",
      "name": "Enviar template Ambientes1",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
                    "rightValue": "projeto",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "ca8a4ae9-6dc3-4e3b-8c9c-eeace058970b"
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "4689d4fc-e11c-4957-a4ce-cf1ee5c371d9",
                    "leftValue": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
                    "rightValue": "plantabaixa",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -380,
        100
      ],
      "id": "d83aa09e-3720-4288-91a1-b553e6b5b098",
      "name": "Arquivos de projeto ou planta baixa??1"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f82b7bb8-a202-4380-b2fd-f96fddb7da7e",
                    "leftValue": "={{ $('Coleta de dados').first().json.mediaPath }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "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": "38f137b1-f86b-4a8b-a68d-eda2713536d1"
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c05e45a2-4632-49ad-b5a0-38dc43fe01ae",
                    "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": [
        -40,
        1640
      ],
      "id": "bfb0e201-e124-4d25-b907-e1b854477013",
      "name": "Achou ou n\u00e3o achou a planta baixa?"
    },
    {
      "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": 7
          },
          "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": true
            },
            {
              "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": [
        840,
        1660
      ],
      "id": "b1d9e945-c33a-4130-9e9d-404c5f400393",
      "name": "Atualizar estado Ambientes1",
      "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\udcdd Para continuarmos, voc\u00ea pode me informar qual ambiente deseja ver e projetar? Mande cada n\u00famero separadamente na mesma mensagem, exemplo: *2 1 3*\\n\\nAs op\u00e7\u00f5es s\u00e3o:\\n\\n1 - \ud83c\udf73 Cozinha\\n2 - \ud83d\udecb\ufe0f Sala de Estar\\n3 - \ud83d\udecf\ufe0f Dormit\u00f3rio\\n4 - \ud83d\udebf Banheiro\\n5 - \ud83c\udf7d\ufe0f Sala de Jantar\\n6 - \ud83c\udf7b Canto Alem\u00e3o\\n7 - \ud83d\udcbb Home Office\\n\\nQuando finalizar o envio mande um \\\"OK\\\"\"\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        600,
        1660
      ],
      "id": "9fcb8d5a-d4fd-442e-bd41-29ed8a2d6a69",
      "name": "Enviar template Ambientes2",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "K3JYvzQkFDZ4Ro9z",
          "mode": "list",
          "cachedResultName": "Armazenar arquivos"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        840,
        1480
      ],
      "id": "ccc31f40-b8f2-4240-a4ff-9a7154fcdb05",
      "name": "Guardar na pasta do cliente1",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "HgYBsJyKgMD50NqY",
          "mode": "list",
          "cachedResultName": "Reconhecimento"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        220,
        2300
      ],
      "id": "7e895e12-08d5-4825-ae68-1f22cbf6558b",
      "name": "Reconhecimento",
      "executeOnce": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6b58d2b9-9329-41b7-b36b-0ccf9b643751",
              "name": "mediaUrl",
              "value": "={{ $('Webhook1').first().json.body.data.mediaUrl }}",
              "type": "string"
            },
            {
              "id": "c8132fc1-2f9a-410c-9b7f-9625cd498012",
              "name": "mediaPath",
              "value": "={{ $('Webhook1').first().json.body.data.mediaPath }}",
              "type": "string"
            },
            {
              "id": "e4810252-8894-42a5-aa75-49ee26392c0a",
              "name": "body",
              "value": "={{ $('Webhook1').first().json.body.data.body }}",
              "type": "string"
            },
            {
              "id": "5d78d2f5-bed3-4e58-88a1-6c06369eacf7",
              "name": "mediaType",
              "value": "={{ $('Webhook1').first().json.body.data.mediaType }}",
              "type": "string"
            },
            {
              "id": "54a42dcb-24ce-42c3-888b-984d3dc53753",
              "name": "ticketId",
              "value": "={{ $('Webhook1').first().json.body.data.ticketId }}",
              "type": "number"
            },
            {
              "id": "cfda8f33-9590-483f-bd27-dd46d125d8ca",
              "name": "contactId",
              "value": "={{ $('Webhook1').first().json.body.data.contactId }}",
              "type": "number"
            },
            {
              "id": "536af937-2ac4-4e8a-86c5-e78e5ff09653",
              "name": "userId",
              "value": "={{ $('Webhook1').first().json.body.data.ticket.userId }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2760,
        580
      ],
      "id": "b09ace0f-6432-41ec-9a36-a8a644759114",
      "name": "Dados cadastro"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -40,
        1320
      ],
      "id": "956c0c26-1faa-499d-8335-246e584429de",
      "name": "Dados servi\u00e7o6"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "njmVImrOZa5TNY7r",
          "mode": "list",
          "cachedResultName": "Projeto"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        180,
        1320
      ],
      "id": "d88609ce-e27a-4704-bce5-e9b8b8ac9a5c",
      "name": "Fim da triagem sem planta baixa",
      "executeOnce": true
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "qPUwHsR0BdZ3Fj6L",
          "mode": "list",
          "cachedResultName": "Primeiro contato"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        -2320,
        340
      ],
      "id": "53813315-0244-45ff-9318-34993ba22320",
      "name": "Primeiro contato"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c585307f-b25f-4bee-a035-3431aa065542",
              "leftValue": "={{ $('Coleta de dados').first().json.body }}",
              "rightValue": "1",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "a2470b6d-8989-4535-a577-65136f056a8c",
              "leftValue": "={{ $('Coleta de dados').first().json.body }}",
              "rightValue": "2",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "2285a7ce-708c-4ba5-982e-b9481c8e115c",
              "leftValue": "={{ $('Coleta de dados').first().json.body }}",
              "rightValue": "3",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "4a92fd15-b7dc-46e2-b70a-5474a397787d",
              "leftValue": "={{ $('Coleta de dados').first().json.body }}",
              "rightValue": "4",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -580,
        -820
      ],
      "id": "5075a152-50bd-4082-a408-3f2fe97cab35",
      "name": "Se n\u00e3o for um dos index"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "GUHgQLwsZmfKpJep",
          "mode": "list",
          "cachedResultName": "Escolha de servi\u00e7o"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {
          "waitForSubWorkflow": true
        }
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        -60,
        -840
      ],
      "id": "eb46d56a-19d1-4e09-89b1-02a1695e8322",
      "name": "Escolha de servi\u00e7o",
      "executeOnce": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "85ebde02-0fac-43a0-a78b-f9f011d14f54",
              "name": "numero",
              "value": "={{ $('Coleta de dados').first().json.number }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2520,
        340
      ],
      "id": "5930a225-98a8-4703-9e92-ff8111dab427",
      "name": "Dados armazenar arquivos2"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "sunWreCC8MPs1JqG",
          "mode": "list",
          "cachedResultName": "Horario escolhido"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        220,
        2100
      ],
      "id": "59294634-e720-4d93-97a2-339986b51304",
      "name": "Agendar usu\u00e1rio",
      "executeOnce": true
    },
    {
      "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,
        -480
      ],
      "id": "bc5e4d62-d046-43a1-9acc-c28ac04fc8c5",
      "name": "Recuperar ticket1",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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,
        -500
      ],
      "id": "bc121a30-f4e8-4fe0-980c-ca51eba9652e",
      "name": "Atualizar data da ultima mensagem1",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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,
        -300
      ],
      "id": "39c9bb28-8efa-4425-88ff-7f46ad8246aa",
      "name": "Recuperar ticket3",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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,
        -320
      ],
      "id": "0887cdde-4a9e-43f8-bb5a-b708687e6e0b",
      "name": "Atualizar data da ultima mensagem3",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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,
        480
      ],
      "id": "6795a978-5f84-4c2e-ac1c-e15b449770f7",
      "name": "Recuperar ticket4",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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,
        460
      ],
      "id": "2da58431-0a1c-4d4a-aa61-75e952e37615",
      "name": "Atualizar data da ultima mensagem4",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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": [
        660,
        640
      ],
      "id": "671b7a5b-7699-4b09-beae-26ae8d560d10",
      "name": "Recuperar ticket5",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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": [
        920,
        620
      ],
      "id": "77b9c641-e578-4c72-9aea-4f02dcf488d2",
      "name": "Atualizar data da ultima mensagem5",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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": [
        1060,
        1660
      ],
      "id": "02f5772a-27da-4122-85b5-3ec7e2d87be6",
      "name": "Recuperar ticket6",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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": [
        1320,
        1640
      ],
      "id": "3e289758-3830-4d28-bd20-1cd1b599a453",
      "name": "Atualizar data da ultima mensagem6",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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": [
        1060,
        1840
      ],
      "id": "602b83ff-9488-40e7-b030-f44552011706",
      "name": "Recuperar ticket7",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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": [
        1320,
        1820
      ],
      "id": "91549714-383c-4590-a270-230a761e9468",
      "name": "Atualizar data da ultima mensagem7",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const createdAt = new Date($('Webhook1').first().json.body.data.ticket.createdAt);\n\nconsole.log(createdAt)\n\n// Ajusta o hor\u00e1rio para UTC-4 (Manaus)\nconst manausOffsetMs = 4 * 60 * 60 * 1000;\nconst createdManaus = new Date(createdAt.getTime() - manausOffsetMs);\n\nconst nowUtc = new Date();\nconst nowManaus = new Date(nowUtc.getTime() - manausOffsetMs);\n\n// Compara apenas ano, m\u00eas e dia\nconst isSameDay =\n    createdManaus.getFullYear() === nowManaus.getFullYear() &&\n    createdManaus.getMonth() === nowManaus.getMonth() &&\n    createdManaus.getDate() === nowManaus.getDate();\n\nreturn [\n  {\n    json: {\n      clienteNovo: isSameDay\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2940,
        360
      ],
      "id": "82e91113-eadc-4fab-bb44-31ce4db5fb2a",
      "name": "Analisar datas de cadastro do contact"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b9fd038b-ed8a-4bc4-8b2b-6c45d481dd92",
              "leftValue": "={{ $json.clienteNovo }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2760,
        360
      ],
      "id": "81a33ec0-c230-437c-aed4-9719ebd95008",
      "name": "Se for um cliente novo?"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d767b4f6-2ef2-44a3-a861-910291b47de0",
              "leftValue": "={{ $('Coleta de dados').first().json.mediaType }}",
              "rightValue": "chat",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -460,
        -640
      ],
      "id": "3a7f8d56-5610-4e0f-8735-da8c6cad35a0",
      "name": "Se for chat",
      "executeOnce": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "86b8c3ca-e05d-44ff-9df2-4fe62e504902",
              "leftValue": "={{ $('Coleta de dados').first().json.body }}",
              "rightValue": "OK",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            },
            {
              "id": "3a4e48de-26fb-4785-a519-508714ffc44d",
              "leftValue": "={{ $('Coleta de dados').first().json.mediaType }}",
              "rightValue": "chat",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -480,
        1160
      ],
      "id": "bc6076a1-f3af-4727-9704-edebd9b0057e",
      "name": "Finalizou pedidos"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "102369bf-ee81-4d3c-82bc-51dae574f3b7",
              "leftValue": "={{ $('Coleta de dados').first().json.mediaType }}",
              "rightValue": "chat",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -260,
        1340
      ],
      "id": "6e8f979b-fee2-40c2-b31f-1307ea2f1092",
      "name": "\u00c9 chat?"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('Analisar ticket').first().json.state }}",
                    "rightValue": 1,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "id": "88ecab6b-4f53-48d5-bfce-3c7d2cbdd938"
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "d95040e3-298d-48cd-8ed8-347024258e2e",
                    "leftValue": "={{ $json.passedOneHour }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "false",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2eb6c8f1-694c-4a36-8315-a032e7dbb846",
                    "leftValue": "={{ $json.passedOneHour }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -2100,
        820
      ],
      "id": "f23e5070-8249-4489-85a3-086e0f1266ba",
      "name": "Template inicial ou n\u00e3o passou de uma hora",
      "executeOnce": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            },
            {
              "id": "b335b3bf-5b85-4743-a0da-305f37de8036",
              "name": "local_arquivo",
              "value": "={{ $('Analisar ticket').first().json.local_arquivo }}",
              "type": "string"
            },
            {
              "id": "e54fb80d-40b9-44dd-8bd4-4815fcf6b2e8",
              "name": "id_atendente",
              "value": "={{ $('Analisar ticket').first().json.id_atendente }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -40,
        2300
      ],
      "id": "708b5565-6471-4adc-8810-3d39148f7923",
      "name": "Dados para fazer o reconhecimento"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -40,
        1900
      ],
      "id": "f8558c37-6cb5-4bde-813a-ba9d9314c1fd",
      "name": "Dados para enviar as datas disponiveis"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            },
            {
              "id": "b37b3e8f-88a4-419b-ab14-2e535c894d40",
              "name": "numero",
              "value": "={{ $('Analisar ticket').first().json.numero }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -40,
        2100
      ],
      "id": "18a5725d-6cc9-4ef3-883a-d7305fa430b8",
      "name": "Dados da escolha do cliente"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "033210d7-32d6-4bad-96b2-18c46f631e44",
              "name": "id",
              "value": "={{ $('Analisar ticket').first().json.id }}",
              "type": "number"
            },
            {
              "id": "9922147e-f2bf-4be2-99a3-02fafd7a2899",
              "name": "mediaPath",
              "value": "={{ $('Coleta de dados').first().json.mediaPath }}",
              "type": "string"
            },
            {
              "id": "918f3fff-7d24-4dcf-bab9-f92b941231f9",
              "name": "body",
              "value": "={{ $('Coleta de dados').first().json.body }}",
              "type": "string"
            },
            {
              "id": "32513e9d-9e86-4166-a170-50fc93f66317",
              "name": "mediaType",
              "value": "={{ $('Coleta de dados').first().json.mediaType }}",
              "type": "string"
            },
            {
              "id": "00499639-bfe1-4db6-abf9-4b524c9f3bf2",
              "name": "ticketId",
              "value": "={{ $('Coleta de dados').first().json.ticketId }}",
              "type": "number"
            },
            {
              "id": "8ee2bc62-12b8-456c-b1e2-f62974950460",
              "name": "contactId",
              "value": "={{ $('Coleta de dados').first().json.contactId }}",
              "type": "number"
            },
            {
              "id": "c5b8a94a-b825-40ca-aa60-aa65a98fb171",
              "name": "userId",
              "value": "={{ $('Coleta de dados').first().json.userId }}",
              "type": "number"
            },
            {
              "id": "80774066-9655-40cc-b231-fe24236ec37a",
              "name": "nome",
              "value": "={{ $('Analisar ticket').first().json.nome }}",
              "type": "string"
            },
            {
              "id": "fd6bb8ba-b64d-420a-aceb-97392916dc13",
              "name": "emAtendimento",
              "value": "={{ $('Analisar ticket').first().json.ematendimento }}",
              "type": "boolean"
            },
            {
              "id": "21c67952-7345-4dff-a661-351ea7258e6a",
              "name": "finalizoutriagem",
              "value": "={{ $('Analisar ticket').first().json.finalizoutriagem }}",
              "type": "boolean"
            },
            {
              "id": "6741deeb-6afd-4f17-b2cc-4cf7c76e149d",
              "name": "lastmessage",
              "value": "={{ $('Analisar ticket').first().json.lastmessage }}",
              "type": "string"
            },
            {
              "id": "119bff22-0d78-4e17-871f-cabe7c64eb7b",
              "name": "state",
              "value": "={{ $('Analisar ticket').first().json.state }}",
              "type": "number"
            },
            {
              "id": "5e250e40-4c46-4072-99c8-fc7b1c23b1bd",
              "name": "fase_arquivos",
              "value": "={{ $('Analisar ticket').first().json.fase_arquivos }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        600,
        1480
      ],
      "id": "1c7485f4-c64f-4c99-834e-3b6d8449eecc",
      "name": "Dados armazenar arquivos da planta baixa"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c76bc20a-4d7e-4ee3-9d03-c69b22f42c0f",
              "leftValue": "={{ $('Coleta de dados').first().json.body }}",
              "rightValue": "RESET",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -3480,
        500
      ],
      "id": "7166f4bd-ed21-44c2-9290-27b6dff9e168",
      "name": "Quer recome\u00e7ar?"
    },
    {
      "parameters": {
        "operation": "deleteTable",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "tb_mensagem_cliente",
          "mode": "list",
          "cachedResultName": "tb_mensagem_cliente"
        },
        "deleteCommand": "delete",
        "where": {
          "values": [
            {
              "column": "contactid",
              "value": "={{ $('Analisar ticket').first().json.contactid }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -2940,
        120
      ],
      "id": "4fb02e7b-d4f9-445b-92ef-2b881a6d88f8",
      "name": "Deletar usuario",
      "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\": \"Ol\u00e1! Eu sou a Vera D\u2019or, sua assistente virtual \ud83d\udcac\\n\\nEstou aqui para te ajudar a transformar seus ambientes com m\u00f3veis planejados do jeitinho que voc\u00ea sempre sonhou! \u2728\\n\\nComo posso te ajudar hoje? Escolha uma das op\u00e7\u00f5es abaixo para come\u00e7armos:\\n\\n1 - Or\u00e7amento \ud83d\udcb0\\n2 - Projeto Executivo \ud83d\udcd0\\n3 - Assist\u00eancia T\u00e9cnica \ud83d\udee0\ufe0f\\n4 - Financeiro \ud83d\udcca\\n\\nCaso queira reiniciar o atendimento, \u00e9 s\u00f3 enviar RESET (pode ser em qualquer momento da conversa)\\n\\n\ud83d\udc49 \u00c9 s\u00f3 me enviar o n\u00famero da op\u00e7\u00e3o desejada!\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2760,
        120
      ],
      "id": "393a4223-8caf-4337-a6a2-4d51aaf799fd",
      "name": "Template Inicial"
    },
    {
      "parameters": {
        "operation": "upsert",
        "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": {
            "ematendimento": false,
            "finalizoutriagem": false,
            "contactid": "={{ $('Webhook1').first().json.body.data.contactId }}",
            "ticketid": "={{ $('Webhook1').first().json.body.data.ticketId }}",
            "userid": "={{ $('Webhook1').first().json.body.data.ticket.userId }}",
            "mediapath": "={{ $('Webhook1').first().json.body.data.mediaPath }}",
            "body": "={{ $('Webhook1').first().json.body.data.body }}",
            "mediatype": "={{ $('Webhook1').first().json.body.data.mediaType }}",
            "state": 1,
            "fase_arquivos": "projeto",
            "numero": "={{ $('Webhook1').first().json.body.data.contact.number }}"
          },
          "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": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "mediatype",
              "displayName": "mediatype",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false
            },
            {
              "id": "ticketid",
              "displayName": "ticketid",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": 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": false
            },
            {
              "id": "lastmessageat",
              "displayName": "lastmessageat",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": false,
              "removed": true
            },
            {
              "id": "nome",
              "displayName": "nome",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "ematendimento",
              "displayName": "ematendimento",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "canBeUsedToMatch": false
            },
            {
              "id": "finalizoutriagem",
              "displayName": "finalizoutriagem",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "canBeUsedToMatch": false
            },
            {
              "id": "stopchatbot",
              "displayName": "stopchatbot",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "canBeUsedToMatch": false,
              "removed": true
            },
            {
              "id": "templateid",
              "displayName": "templateid",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": false,
              "removed": true
            },
            {
              "id": "pararmensagem",
              "displayName": "pararmensagem",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "canBeUsedToMatch": false,
              "removed": true
            },
            {
              "id": "lastmessage",
              "displayName": "lastmessage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "state",
              "displayName": "state",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "fase_arquivos",
              "displayName": "fase_arquivos",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "local_arquivo",
              "displayName": "local_arquivo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "id_atendente",
              "displayName": "id_atendente",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "data_medicao",
              "displayName": "data_medicao",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "numero",
              "displayName": "numero",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -2560,
        120
      ],
      "id": "50a25f0e-3cf4-43fd-b430-21ce20727da1",
      "name": "Cadastrar contato",
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://cmmodulados.gosac.com.br/api/tickets/{{ $('Webhook1').first().json.body.data.ticketId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "INTEGRATION 0ddfe6600ac270ae602f509c3bf247dd8b581fe6672dc48fcb2853d91328"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2380,
        120
      ],
      "id": "b5524c09-aa4b-4af8-9779-cb1d51900171",
      "name": "Recuperar ticket2",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "onError": "continueErrorOutput"
    },
    {
      "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": [
        -2140,
        100
      ],
      "id": "ac3a2c0c-6941-47b6-859e-ae1f9a80f651",
      "name": "Atualizar data da ultima mensagem2",
      "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\udd0e Selecione uma das duas op\u00e7\u00f5es para continuarmos com o atendimento. \ud83d\ude80\\n\\n1 - Achei e enviei a planta baixa.\\n2 - N\u00e3o encontrei a minha planta baixa.\"\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        400,
        640
      ],
      "id": "25959475-5f7a-4140-bf97-6f3738dfb4df",
      "name": "Enviar template perguntando sobre se encontrou ou n\u00e3o a planta baixa",
      "alwaysOutputData": false
    }
  ],
  "connections": {
    "Webhook1": {
      "main": [
        [
          {
            "node": "Se a mensagem n\u00e3o for um hsm ou um transfer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Comparar tempo": {
      "main": [
        [
          {
            "node": "Template inicial ou n\u00e3o passou de uma hora",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se o atendimento do cliente est\u00e1 fechado": {
      "main": [
        [
          {
            "node": "Dados cadastro",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Se o cliente est\u00e1 em atendimento pessoal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se o cliente est\u00e1 em atendimento pessoal": {
      "main": [
        [],
        [
          {
            "node": "Comparar tempo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Encaminhar template de desencontro": {
      "main": [
        [
          {
            "node": "Reiniciar chatbot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se a mensagem n\u00e3o for um hsm ou um transfer": {
      "main": [
        [
          {
            "node": "Se for arquivo",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Analisar ticket": {
      "main": [
        [
          {
            "node": "Quer recome\u00e7ar?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reiniciar chatbot": {
      "main": [
        [
          {
            "node": "Dados cadastro",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Armazenar primeira mensagem": {
      "main": [
        [
          {
            "node": "Debounce",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar ultima mensagem": {
      "main": [
        [
          {
            "node": "\u00c9 a mesma mensagem?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Debounce": {
      "main": [
        [
          {
            "node": "Buscar ultima mensagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u00c9 a mesma mensagem?": {
      "main": [
        [
          {
            "node": "Coleta de dados",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Se o estado do cliente": {
      "main": [
        [
          {
            "node": "Se n\u00e3o for um dos index",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Se for chat",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tem ou nao projeto",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Finalizou o envio dos arquivos?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tem ou n\u00e3o planta baixa??",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Dados servi\u00e7o1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Finalizou pedidos",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Achou ou n\u00e3o achou a planta baixa?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Dados para enviar as datas disponiveis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Dados da escolha do cliente",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Dados para fazer o reconhecimento",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tem ou nao projeto": {
      "main": [
        [
          {
            "node": "Enviar template do Tenho Projeto",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar template da Planta Baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template do Tenho Projeto": {
      "main": [
        [
          {
            "node": "Atualizar estado Tenho Projeto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template da Planta Baixa": {
      "main": [
        [
          {
            "node": "Atualizar estado Planta Baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Finalizou o envio dos arquivos?": {
      "main": [
        [
          {
            "node": "Dados armazenar arquivos",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Arquivos de projeto ou planta baixa??1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tem ou n\u00e3o planta baixa??": {
      "main": [
        [
          {
            "node": "Enviar template Tem Planta Baixa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar template N\u00e3o Tem Planta Baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template Tem Planta Baixa": {
      "main": [
        [
          {
            "node": "Atualizar estado Tenho Planta Baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Coleta de dados": {
      "main": [
        [
          {
            "node": "Analisar ticket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template N\u00e3o Tem Planta Baixa": {
      "main": [
        [
          {
            "node": "Atualizar estado N\u00e3o Tenho Planta Baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se for arquivo": {
      "main": [
        [
          {
            "node": "Coleta de dados",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Armazenar primeira mensagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cliente novo?": {
      "main": [
        [
          {
            "node": "Analisar datas de cadastro do contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Se o atendimento do cliente est\u00e1 fechado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado Tenho Projeto": {
      "main": [
        [
          {
            "node": "Recuperar ticket1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado Planta Baixa": {
      "main": [
        [
          {
            "node": "Recuperar ticket3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado Ambientes": {
      "main": [
        [
          {
            "node": "Recuperar ticket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado Tenho Planta Baixa": {
      "main": [
        [
          {
            "node": "Recuperar ticket4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado N\u00e3o Tenho Planta Baixa": {
      "main": [
        [
          {
            "node": "Enviar template perguntando sobre se encontrou ou n\u00e3o a planta baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado Agendamento": {
      "main": [
        [
          {
            "node": "Recuperar ticket7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template N\u00e3o achou a planta baixa": {
      "main": [
        [
          {
            "node": "Atualizar estado Agendamento",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Adicionar nome": {
      "main": [
        [
          {
            "node": "Buscar Cliete Driver",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Cliete Driver": {
      "main": [
        [
          {
            "node": "Enviar para cria\u00e7\u00e3o do ambiente do lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados servi\u00e7o": {
      "main": [
        [
          {
            "node": "Escolha de servi\u00e7o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados armazenar arquivos": {
      "main": [
        [
          {
            "node": "Guardar na pasta do cliente",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados entregou o projeto": {
      "main": [
        [
          {
            "node": "Entregou projeto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados servi\u00e7o1": {
      "main": [
        [
          {
            "node": "Enviar refer\u00eancias",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados servi\u00e7o2": {
      "main": [
        [
          {
            "node": "Cliente escolhe ou n\u00e3o o ambiente",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template Ambientes1": {
      "main": [
        [
          {
            "node": "Atualizar estado Ambientes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Arquivos de projeto ou planta baixa??1": {
      "main": [
        [
          {
            "node": "Dados entregou o projeto",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar template Ambientes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Achou ou n\u00e3o achou a planta baixa?": {
      "main": [
        [
          {
            "node": "Dados armazenar arquivos da planta baixa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar template Ambientes2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar template N\u00e3o achou a planta baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template Ambientes2": {
      "main": [
        [
          {
            "node": "Atualizar estado Ambientes1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados cadastro": {
      "main": [
        [
          {
            "node": "Estado clente",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados servi\u00e7o6": {
      "main": [
        [
          {
            "node": "Fim da triagem sem planta baixa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar estado Ambientes1": {
      "main": [
        [
          {
            "node": "Recuperar ticket6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se n\u00e3o for um dos index": {
      "main": [
        [
          {
            "node": "Dados servi\u00e7o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados armazenar arquivos2": {
      "main": [
        [
          {
            "node": "Primeiro contato",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket1": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket3": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket4": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket5": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket6": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket7": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analisar datas de cadastro do contact": {
      "main": [
        [
          {
            "node": "Se for um cliente novo?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se for um cliente novo?": {
      "main": [
        [
          {
            "node": "Dados armazenar arquivos2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Se for chat": {
      "main": [
        [
          {
            "node": "Adicionar nome",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Finalizou pedidos": {
      "main": [
        [
          {
            "node": "Dados servi\u00e7o2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u00c9 chat?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u00c9 chat?": {
      "main": [
        [
          {
            "node": "Dados servi\u00e7o6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Template inicial ou n\u00e3o passou de uma hora": {
      "main": [
        [
          {
            "node": "Se o estado do cliente",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Se o estado do cliente",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Encaminhar template de desencontro",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados para fazer o reconhecimento": {
      "main": [
        [
          {
            "node": "Reconhecimento",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados para enviar as datas disponiveis": {
      "main": [
        [
          {
            "node": "Agendamento de medi\u00e7\u00e3o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados da escolha do cliente": {
      "main": [
        [
          {
            "node": "Agendar usu\u00e1rio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dados armazenar arquivos da planta baixa": {
      "main": [
        [
          {
            "node": "Guardar na pasta do cliente1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quer recome\u00e7ar?": {
      "main": [
        [
          {
            "node": "Deletar usuario",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Cliente novo?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deletar usuario": {
      "main": [
        [
          {
            "node": "Template Inicial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Template Inicial": {
      "main": [
        [
          {
            "node": "Cadastrar contato",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cadastrar contato": {
      "main": [
        [
          {
            "node": "Recuperar ticket2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recuperar ticket2": {
      "main": [
        [
          {
            "node": "Atualizar data da ultima mensagem2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar template perguntando sobre se encontrou ou n\u00e3o a planta baixa": {
      "main": [
        [
          {
            "node": "Recuperar ticket5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c1aeae5a-f0a4-422a-826c-647ea57974cb",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "mnOihXW9M7ipKQ3P",
  "tags": []
}