{
  "name": "Gmail attachments Demo",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {},
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        -740,
        140
      ],
      "id": "3dcf0a69-79eb-43bc-b8b6-7ce7b329bee8",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "id": "nmzi3IDotki1DDbf",
          "name": "Gmail account 2"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "simple": false,
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -300,
        140
      ],
      "id": "2e8ec256-0c51-408f-9f39-dc5adc784984",
      "name": "Gmail",
      "webhookId": "b7f54ce6-0bb8-45d3-970c-76fda0729899",
      "credentials": {
        "gmailOAuth2": {
          "id": "nmzi3IDotki1DDbf",
          "name": "Gmail account 2"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5638d863-0e83-4214-9c7c-3027a05f8ac7",
              "name": "attachments_metadata",
              "value": "={{ $('Gmail').item.binary.values() }}",
              "type": "array"
            },
            {
              "id": "a465a1ea-9c6d-431a-ad3f-c272ee79a5be",
              "name": "message_id",
              "value": "={{ $('Gmail').item.json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -80,
        280
      ],
      "id": "82281ba0-21ee-4fce-aff4-90bbb6625a05",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "fieldToSplitOut": "attachments_metadata",
        "include": "allOtherFields",
        "options": {
          "includeBinary": true
        }
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        140,
        280
      ],
      "id": "97705c11-6b8d-4aaa-9f5c-7afc7f5642fc",
      "name": "Split Out"
    },
    {
      "parameters": {
        "mode": "combine",
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "message_id",
              "field2": "id"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        800,
        60
      ],
      "id": "f24dce1f-bd8d-45f4-86c0-ed27f6a6dc17",
      "name": "Merge"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a9ea58b8-305b-4a36-9ae4-67144354a177",
              "leftValue": "={{ $('Gmail Trigger').item.binary }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -520,
        140
      ],
      "id": "dae2323a-d3c8-40db-ad23-32891fd8ec53",
      "name": "Filter"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5638d863-0e83-4214-9c7c-3027a05f8ac7",
              "name": "attachments",
              "value": "={{ $('Gmail').item.binary.keys() }}",
              "type": "array"
            },
            {
              "id": "a465a1ea-9c6d-431a-ad3f-c272ee79a5be",
              "name": "message_id",
              "value": "={{ $('Gmail').item.json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -80,
        -20
      ],
      "id": "4e268fc7-b439-4548-9233-4c12357e904b",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "fieldToSplitOut": "attachments",
        "include": "allOtherFields",
        "options": {
          "includeBinary": false
        }
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        140,
        -20
      ],
      "id": "37092899-31a0-49ce-bac7-83918db5eedf",
      "name": "Split Out1"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        360,
        -20
      ],
      "id": "62b47ef0-5a16-463f-9b72-e4c12fb44ca7",
      "name": "Merge1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a87b73db-6cd9-4b37-bb89-11e265ba61af",
              "leftValue": "={{ $json.attachments_metadata.fileType }}",
              "rightValue": "pdf",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        580,
        -20
      ],
      "id": "bd7af470-eff4-46df-bd7d-92ce6d0d3a88",
      "name": "Filter1"
    },
    {
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "={{ $json.attachments }}",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1060,
        60
      ],
      "id": "4572dc9f-4745-4b48-b422-855a7160a266",
      "name": "Extract from File1"
    }
  ],
  "pinData": {},
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          },
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Split Out1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Filter1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Extract from File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File1": {
      "main": [
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2406bb37-6851-445c-b9c2-6e9273ef5a22",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": ""
  },
  "id": "ARhfZzpj56uJc5um",
  "tags": []
}