{
  "name": "w4a-invoice-exchange",
  "nodes": [
    {
      "parameters": {
        "resource": "folder",
        "displayName": "Neue Eingangsrechnungen",
        "options": {}
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        -544,
        -64
      ],
      "id": "8fddf03c-5b4f-42c4-b983-bbf4e04cce10",
      "name": "Create Folder: Neue Eingangsrechnungen",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "folder",
        "displayName": "Fehler",
        "options": {}
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        -288,
        -64
      ],
      "id": "0b835200-d028-4076-9950-9b631d810bfa",
      "name": "Create Folder: Fehler",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "folder",
        "displayName": "Verarbeitet",
        "options": {}
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        -48,
        -64
      ],
      "id": "5291d773-01ed-4a76-a605-634acff41575",
      "name": "Create Folder: Verarbeitet",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "foldersToInclude": [
            "AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdLAAA="
          ]
        },
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.microsoftOutlookTrigger",
      "typeVersion": 1,
      "position": [
        -752,
        320
      ],
      "id": "6b06375b-dca3-43a1-94ca-a24bd0305bac",
      "name": "Trigger: Emails in Neue Eingangsrechnungen",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "move",
        "messageId": {
          "__rl": true,
          "value": "AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwBGAAAAAAB0sAUOHy4fSK8zXAyosp7vBwD5F53ZtU8FQ5T0NXXlFAlwAAAAAAEMAAD5F53ZtU8FQ5T0NXXlFAlwAAAYN8WJAAA=",
          "mode": "list",
          "cachedResultName": "2-attachments",
          "cachedResultUrl": "https://outlook.office365.com/owa/?ItemID=AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwBGAAAAAAB0sAUOHy4fSK8zXAyosp7vBwD5F53ZtU8FQ5T0NXXlFAlwAAAAAAEMAAD5F53ZtU8FQ5T0NXXlFAlwAAAYN8WJAAA%3D&exvsurl=1&viewmodel=ReadMessageItem"
        },
        "folderId": {
          "__rl": true,
          "value": "AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdLAAA=",
          "mode": "list",
          "cachedResultName": "Neue Eingangsrechnungen",
          "cachedResultUrl": "https://outlook.office365.com/mail/AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdLAAA%3D"
        }
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        -960,
        32
      ],
      "id": "fd4d88bf-0961-4ca1-9969-9c5780ab5244",
      "name": "Move to Eingangsrechnungen",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "move",
        "messageId": {
          "__rl": true,
          "value": "={{ $('Trigger: Emails in Neue Eingangsrechnungen').item.json.id }}",
          "mode": "id"
        },
        "folderId": {
          "__rl": true,
          "value": "AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdMAAA=",
          "mode": "list",
          "cachedResultName": "Fehler",
          "cachedResultUrl": "https://outlook.office365.com/mail/AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdMAAA%3D"
        }
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        672,
        304
      ],
      "id": "7c33dece-9eba-4330-8820-8652e25465e5",
      "name": "Move into Fehler Folder",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "d26a6695-69cd-4253-a407-9ced41587f40",
              "leftValue": "={{ $json.errors }}",
              "rightValue": "",
              "operator": {
                "type": "array",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -32,
        160
      ],
      "id": "51b9724c-9ebc-44eb-a5a2-58c1e264e9e3",
      "name": "Has Errors?"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "pJ8yNsaBKgLj6THO",
          "mode": "list",
          "cachedResultUrl": "/workflow/pJ8yNsaBKgLj6THO",
          "cachedResultName": "work4all-invoice-workflow"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.3,
      "position": [
        -464,
        288
      ],
      "id": "a3673552-3479-468e-9a50-616f04cdfab1",
      "name": "Call 'work4all-invoice-workflow'",
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "toRecipients": "laurin@atroo.de",
        "subject": "Da ist was schiefgelaufen",
        "bodyContent": "={{ $('Call \\'work4all-invoice-workflow\\'').item.json.error ?? $('Call \\'work4all-invoice-workflow\\'').item.json.errors.toJsonString() }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        432,
        368
      ],
      "id": "1f8e3657-5def-4394-aed1-c841dfed0c65",
      "name": "Send Error Message",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "move",
        "messageId": {
          "__rl": true,
          "value": "={{ $json.outlookMessageId }}",
          "mode": "id"
        },
        "folderId": {
          "__rl": true,
          "value": "AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdNAAA=",
          "mode": "list",
          "cachedResultName": "Verarbeitet",
          "cachedResultUrl": "https://outlook.office365.com/mail/AAMkAGVhNzdlZmNjLWFkNjItNGMzMi04YzZkLWE4YTFkYWY4NTI3NwAuAAAAAAB0sAUOHy4fSK8zXAyosp7vAQD5F53ZtU8FQ5T0NXXlFAlwAAAcbEdNAAA%3D"
        }
      },
      "type": "n8n-nodes-base.microsoftOutlook",
      "typeVersion": 2,
      "position": [
        352,
        32
      ],
      "id": "383b088a-a652-4fbf-a809-7c111f5cdf92",
      "name": "Move into Verarbeitet",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return {'error':$input.first().json.error }"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -256,
        288
      ],
      "id": "673c5e06-99d9-4319-872d-df69ead010a0",
      "name": "Code in JavaScript"
    }
  ],
  "connections": {
    "Create Folder: Neue Eingangsrechnungen": {
      "main": [
        [
          {
            "node": "Create Folder: Fehler",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Folder: Fehler": {
      "main": [
        [
          {
            "node": "Create Folder: Verarbeitet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Emails in Neue Eingangsrechnungen": {
      "main": [
        [
          {
            "node": "Call 'work4all-invoice-workflow'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move into Fehler Folder": {
      "main": [
        []
      ]
    },
    "Has Errors?": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Move into Verarbeitet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call 'work4all-invoice-workflow'": {
      "main": [
        [
          {
            "node": "Has Errors?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move into Verarbeitet": {
      "main": [
        []
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Error Message": {
      "main": [
        [
          {
            "node": "Move into Fehler Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "0809d2a5-62d5-47f9-9df8-d97c250703a4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "V63SIFVQm3TABx2M",
  "tags": []
}