{
  "name": "Protocolo Vale Verde",
  "nodes": [
    {
      "parameters": {
        "content": "## Plano B do Exercício 1\n\nAbra o nó **Gravar na tabela** e escolha a tabela **protocolos** em Data table. Confira que as sete colunas estão mapeadas. Depois: Execute workflow, preencha o formulário, Publish.",
        "width": 520,
        "height": 220
      },
      "id": "43518ef5-e868-4fc7-9ba0-e498b2a8f78f",
      "name": "Nota 2dda",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -260
      ]
    },
    {
      "parameters": {
        "formTitle": "Secretaria da Fazenda de Vale Verde: abrir protocolo",
        "formDescription": "Preencha os campos e envie. Você recebe o número do protocolo na tela.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Nome completo",
              "fieldName": "nome",
              "requiredField": true
            },
            {
              "fieldLabel": "E-mail",
              "fieldType": "email",
              "fieldName": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Tipo de pedido",
              "fieldType": "dropdown",
              "fieldName": "tipo",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Dúvida sobre IPTU"
                  },
                  {
                    "option": "Certidão negativa"
                  },
                  {
                    "option": "Parcelamento de débito"
                  },
                  {
                    "option": "Reclamação"
                  },
                  {
                    "option": "Outro"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Descrição do pedido",
              "fieldType": "textarea",
              "fieldName": "descricao",
              "requiredField": true
            }
          ]
        },
        "options": {
          "buttonLabel": "Enviar",
          "ignoreBots": true
        }
      },
      "id": "2dc180bc-ce81-48c5-aad2-f7cf91c585cd",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        0
      ],
      "webhookId": "c9732f3f-fc95-43ad-ae49-2f5ea8f34eef"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d3a060e2-c890-4937-9a8b-901819b15ca0",
              "name": "protocolo",
              "value": "=VV-{{ $now.toFormat(\"yyyyLLdd-HHmmss\") }}",
              "type": "string"
            },
            {
              "id": "5d3ffa3c-fece-4376-9306-d06a8a303762",
              "name": "criado_em",
              "value": "={{ $now.toFormat(\"dd/LL/yyyy HH:mm\") }}",
              "type": "string"
            },
            {
              "id": "bd20cc54-c284-44f3-995c-aeef88b3f731",
              "name": "status",
              "value": "novo",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "ead675e6-2d14-4fd3-80ae-1446cf4f00dd",
      "name": "Número de protocolo",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "operation": "insert",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "protocolos"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "protocolo": "={{ $json.protocolo }}",
            "nome": "={{ $json.nome }}",
            "email": "={{ $json.email }}",
            "tipo": "={{ $json.tipo }}",
            "descricao": "={{ $json.descricao }}",
            "status": "={{ $json.status }}",
            "criado_em": "={{ $json.criado_em }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "protocolo",
              "displayName": "protocolo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "nome",
              "displayName": "nome",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "tipo",
              "displayName": "tipo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "descricao",
              "displayName": "descricao",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "criado_em",
              "displayName": "criado_em",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "47edb442-b036-48ce-9dde-8054cbcab361",
      "name": "Gravar na tabela",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "operation": "completion",
        "completionTitle": "Protocolo aberto",
        "completionMessage": "=Recebemos o seu pedido. O seu número de protocolo é {{ $('Número de protocolo').first().json.protocolo }}. Guarde este número para acompanhar o pedido.",
        "options": {}
      },
      "id": "6db9f5b1-5824-417b-b23b-ce844aeb3d5c",
      "name": "Confirmação na tela",
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.5,
      "position": [
        780,
        0
      ],
      "webhookId": "10d65cb9-f3d3-41ff-939f-e3af8bdb793e"
    }
  ],
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Número de protocolo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Número de protocolo": {
      "main": [
        [
          {
            "node": "Gravar na tabela",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gravar na tabela": {
      "main": [
        [
          {
            "node": "Confirmação na tela",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Sao_Paulo"
  },
  "pinData": {}
}