{
  "name": "PPS \u2014 02 Gmail Sync",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 7,13,19 * * 1-5"
            }
          ]
        }
      },
      "id": "cron",
      "name": "Cron 7/13/19 L-V",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "operation": "getAll",
        "returnAll": true,
        "filters": {
          "labelIds": [
            "INBOX"
          ],
          "q": "newer_than:14d -category:promotions -category:social -category:forums -from:noreply -from:no-reply -from:notifications -from:newsletter -from:updates -from:hello -from:team -from:security -from:billing -from:@openrouter.ai -from:@n8n.io -from:@supabase.io -from:@supabase.com -from:@baserow.io -from:@github.com -from:@google.com -from:@accounts.google.com -from:@docs.google.com -from:@accounts.youtube.com"
        },
        "options": {}
      },
      "id": "gmail-list",
      "name": "Gmail: list recent",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        520,
        300
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { messages: $input.all().map(item => item.json) } }];"
      },
      "id": "code-payload",
      "name": "Preparar payload Hermes",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        800,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://pps-hermes.n8n-blas.com.ar/tasks/sync_gmail_messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "hermes-sync",
      "name": "Hermes: sync gmail_hilos",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1080,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://pps-hermes.n8n-blas.com.ar/tasks/draft_pending_emails",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ limit: 10, only_missing: true }) }}",
        "options": {}
      },
      "id": "hermes-drafts",
      "name": "Hermes: preparar borradores",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1340,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Cron 7/13/19 L-V": {
      "main": [
        [
          {
            "node": "Gmail: list recent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail: list recent": {
      "main": [
        [
          {
            "node": "Preparar payload Hermes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preparar payload Hermes": {
      "main": [
        [
          {
            "node": "Hermes: sync gmail_hilos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hermes: sync gmail_hilos": {
      "main": [
        [
          {
            "node": "Hermes: preparar borradores",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Argentina/Buenos_Aires"
  }
}