{
  "name": "QuepasaAutomatic",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "seconds"
            }
          ]
        }
      },
      "id": "fb5139b0-6c59-47bf-8daf-637cc449340f",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        540,
        520
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO \"contacts\" (\"name\", \"identifier\", \"account_id\", \"created_at\", \"updated_at\", \"last_activity_at\") VALUES ('Quepasa Control', 'control@quepasa.io', {{ $json.account }}, NOW(), NOW(), NOW());",
        "additionalFields": {}
      },
      "id": "6a16cd70-0786-48c8-bfa2-78b19a4f29f5",
      "name": "Cria o Contato",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        1040,
        640
      ],
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true,
      "notes": "Sucesso"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO \"automation_rules\" (\"account_id\", \"name\", \"description\", \"event_name\", \"conditions\", \"actions\", \"created_at\", \"updated_at\", \"active\") VALUES ({{ $json.account }}, 'Start Quepasa', 'Start Quepasa', 'message_created', '[{\"values\": [\"/qrcode\"], \"attribute_key\": \"content\", \"filter_operator\": \"contains\", \"custom_attribute_type\": \"\"}]', '[{\"action_name\": \"send_webhook_event\", \"action_params\": [\"https://n8n.socialatendimento.com.br/webhook/quepasa\"]}, {\"action_name\": \"send_webhook_event\", \"action_params\": [\"https://n8n.socialatendimento.com.br/webhook-test/quepasa\"]}]', '2023-03-10 14:20:34.326753', '2023-03-10 14:20:34.326753', 'true');",
        "additionalFields": {}
      },
      "id": "4c35a170-0a3b-4a3e-a5d6-ab8ae46e49c7",
      "name": "Cria Automa\u00e7\u00e3o",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        1040,
        420
      ],
      "alwaysOutputData": true,
      "notesInFlow": false,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true,
      "notes": "Sucesso"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=SELECT \"accounts\".\"id\" AS \"account\" FROM \"accounts\" LEFT JOIN \"automation_rules\" ON \"accounts\".\"id\" = \"automation_rules\".\"account_id\" AND \"automation_rules\".\"name\" = 'Start Quepasa' WHERE \"automation_rules\".\"name\" IS NULL;",
        "additionalFields": {}
      },
      "id": "7fe8640e-2196-426b-ad5b-28815ebc9208",
      "name": "Missing Automations",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        800,
        420
      ],
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true,
      "notes": "Sucesso"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=SELECT \"accounts\".\"id\" AS \"account\" FROM \"accounts\" LEFT JOIN \"contacts\" ON \"accounts\".\"id\" = \"contacts\".\"account_id\" AND \"contacts\".\"identifier\" = 'control@quepasa.io' WHERE \"contacts\".\"identifier\" IS NULL;",
        "additionalFields": {}
      },
      "id": "f1e836f3-aabf-45e1-bfc9-1daeda52728f",
      "name": "Missing Quepasa Contact",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        800,
        640
      ],
      "alwaysOutputData": true,
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true,
      "notes": "Sucesso"
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Missing Automations",
            "type": "main",
            "index": 0
          },
          {
            "node": "Missing Quepasa Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Missing Automations": {
      "main": [
        [
          {
            "node": "Cria Automa\u00e7\u00e3o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Missing Quepasa Contact": {
      "main": [
        [
          {
            "node": "Cria o Contato",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "96a95d80-5cae-4318-a139-dd04c60bb67a",
  "id": "5",
  "tags": []
}