{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "B699F514-F358-49DC-86FF-265CD9355DD2",
    "name": "Fatture in Cloud: supplier e-invoice routing"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": 152.07571993210877,
        "y": -89.58931211835852,
        "zoom": 0.5547847360339224
      },
      "autoSave": true,
      "descriptions": {
        "flow": "When a supplier e-invoice arrives, checks the supplier and the supplier order. A clean match is filed with its file attached and noted in Slack; a new supplier or an amount out of line goes to the cost center owner for approval first.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a supplier e-invoice arrives, checks the supplier and the supplier order. A clean match is filed with its file attached and noted in Slack; a new supplier or an amount out of line goes to the cost center owner for approval first.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Uploads a file to Fatture in Cloud and returns the token that attaches it to an issued document, a received document, an F24 or an archive record.",
          "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::uploadAttachment",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Upload the invoice file Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::uploadAttachment",
          "legacyElementId": "JS###v1###FattureInCloudService###uploadAttachment",
          "methodName": "uploadAttachment",
          "position": {
            "x": 657.3309946643578,
            "y": 753.2427377819666
          }
        },
        "flowElementId": "9F6CFF00-F757-4BEF-A945-239C33D92D74",
        "groupId": null,
        "id": "EBA4DC33-C612-4765-B364-C162266E0895",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "filename",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice file",
                    "subPathSegments": [
                      {
                        "key": "filename",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E9793408-8AEF-4294-BE06-2B6C52E72636"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice file",
                    "subPathSegments": [
                      {
                        "key": "content",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E9793408-8AEF-4294-BE06-2B6C52E72636"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "target",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "received_documents"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Upload the invoice file', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "uploadAttachment",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Uploaded file",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fatture-in-cloud",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Upload the invoice file",
        "nextElementIds": [
          "2CF8319A-D6B2-4B2A-8621-1A824F96680A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Starts the flow when Fatture in Cloud raises the chosen event: a document being created, updated, deleted or emailed, an electronic invoice changing status or arriving, a client, supplier or product changing, or a cashbook, receipt or tax entry being added. FlowRunner registers the subscription for you and removes it when the trigger is switched off.",
          "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::onFattureInCloudEvent",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::onFattureInCloudEvent",
          "legacyElementId": "JS###v1###FattureInCloudService###onFattureInCloudEvent",
          "methodName": "onFattureInCloudEvent",
          "position": {
            "x": 110,
            "y": 200
          }
        },
        "flowElementId": "481DA0F1-18FB-4D6D-A1A8-5AFBDFA4CE23",
        "groupId": null,
        "id": "7DA0D839-F686-4B03-8B0B-343821C0DF77",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": "Block: 'New supplier e-invoice', Error: OAuth Connection is required",
            "valid": false
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onFattureInCloudEvent",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New e-invoice",
          "scope": "SINGLE_APP",
          "serviceId": "fatture-in-cloud",
          "slaConditions": [],
          "staticData": {
            "event": "it.fattureincloud.webhooks.received_documents.e_invoices.receive"
          },
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New supplier e-invoice",
        "nextElementIds": [
          "34BF087E-01D7-4329-ABF7-360EC452356C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask the cost center owner Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 213.12651093804493,
            "y": 544.5752128009822
          }
        },
        "flowElementId": "4B05387C-1B4C-4711-9046-B25E7E3CBB30",
        "groupId": null,
        "id": "89012942-6F43-4FD0-A0D4-8C034D0F07B4",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Approval card",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BCB6729B-D8EB-43D9-9DB5-991EB877C7A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Approval card",
                    "subPathSegments": [
                      {
                        "key": "blocks",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BCB6729B-D8EB-43D9-9DB5-991EB877C7A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Approval question",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask the cost center owner",
        "nextElementIds": [
          "17A750B4-3CAE-40FF-9337-E04034487D9A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Records a supplier invoice or other cost in a Fatture in Cloud company.",
          "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::createReceivedDocument",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "File the supplier invoice Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::createReceivedDocument",
          "legacyElementId": "JS###v1###FattureInCloudService###createReceivedDocument",
          "methodName": "createReceivedDocument",
          "position": {
            "x": 1203.0834770851463,
            "y": 951.5178395563494
          }
        },
        "flowElementId": "586397A8-DF1D-4285-B0D1-82268F3EC485",
        "groupId": null,
        "id": "DC27CA94-2CC9-4EA1-8F6D-867D14761C88",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "entityId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Cost record",
                    "subPathSegments": [
                      {
                        "key": "supplierId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "2CF8319A-D6B2-4B2A-8621-1A824F96680A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "documentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "expense"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "date",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "date",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "invoiceNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "amountNet",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "amount_net",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "amountVat",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "amount_vat",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "amountGross",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "amount_gross",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "category",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "description",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "subject",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "items",
              "type": "COMPLEX_LIST",
              "value": []
            },
            {
              "name": "payments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Cost record",
                    "subPathSegments": [
                      {
                        "key": "payments",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "2CF8319A-D6B2-4B2A-8621-1A824F96680A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "properties",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Cost record",
                    "subPathSegments": [
                      {
                        "key": "properties",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "2CF8319A-D6B2-4B2A-8621-1A824F96680A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'File the supplier invoice', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createReceivedDocument",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Filed invoice",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fatture-in-cloud",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "File the supplier invoice",
        "nextElementIds": [
          "81ED7796-5BBC-405D-B1C8-5B86322A6731"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Prepare the cost record Result"
          },
          "position": {
            "x": 1199.6811241953903,
            "y": 782.0827525855134
          }
        },
        "flowElementId": "E60DCD34-186C-48E6-933F-F1FFB2EEA4E7",
        "groupId": null,
        "id": "2CF8319A-D6B2-4B2A-8621-1A824F96680A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "newSupplierId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "New supplier",
                    "subPathSegments": [
                      {
                        "key": "data",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DBB197A8-931E-4E96-AAD6-7F45F490AAD6"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "supplierId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "supplierId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pendingPayments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "payments_list",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "token",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Uploaded file",
                    "subPathSegments": [
                      {
                        "key": "data",
                        "optional": false
                      },
                      {
                        "key": "attachment_token",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "EBA4DC33-C612-4765-B364-C162266E0895"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const id = newSupplierId || supplierId;\nif (!id) throw new Error('There is no supplier to file this invoice against.');\nconst payments = (Array.isArray(pendingPayments) ? pendingPayments : [])\n  .filter(p => p && p.amount)\n  .map(p => ({ due_date: p.due_date, amount: p.amount, status: 'not_paid' }));\nreturn { supplierId: String(id), payments, properties: { attachment_token: token } };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Cost record",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Prepare the cost record",
        "nextElementIds": [
          "DC27CA94-2CC9-4EA1-8F6D-867D14761C88"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the approval request Result"
          },
          "position": {
            "x": 215.1316608239535,
            "y": 402.17763970847074
          }
        },
        "flowElementId": "5E7E4428-FFF0-4856-B4AD-DB846F525471",
        "groupId": null,
        "id": "BCB6729B-D8EB-43D9-9DB5-991EB877C7A5",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "supplier",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "supplier_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "invoiceNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "date",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "date",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "gross",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "amount_gross",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "currency",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "currency",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "costCenter",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "cost_center",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "summary",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "summary",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "newSupplier",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "newSupplier",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "orderNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "withinTolerance",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "withinTolerance",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "aboveHistory",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "aboveHistory",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lineDifferences",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "lineDifferences",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "attachment_url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answerLink",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Answer link",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Answer link"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "executionId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_ID",
                    "label": null,
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.executionId",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "executionId",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const yes = v => v === true || v === 'true';\nconst link = d => `${answerLink}?execution=${encodeURIComponent(executionId)}&decision=${d}`;\nconst reasons = [];\nif (yes(newSupplier)) reasons.push('New supplier, not yet in Fatture in Cloud');\nif (!orderNumber) reasons.push('No supplier order matches this invoice');\nelse if (!yes(withinTolerance)) reasons.push(`The amount is outside the tolerance against order ${orderNumber}`);\nif (yes(aboveHistory)) reasons.push('Higher than anything this supplier has billed before');\nif (lineDifferences) reasons.push(lineDifferences);\nconst lines = [\n  '*Supplier invoice waiting for your approval*',\n  `${supplier}${invoiceNumber ? `, invoice ${invoiceNumber}` : ''}, dated ${date}, ${gross} ${currency || 'EUR'} gross${costCenter ? `, cost center ${costCenter}` : ''}`,\n  summary,\n  ...reasons.map(r => `- ${r}`),\n  fileUrl ? `<${fileUrl}|Open the invoice file>` : null,\n].filter(Boolean);\nreturn {\n  text: `Supplier invoice from ${supplier} is waiting for your approval`,\n  blocks: [\n    { type: 'section', text: { type: 'mrkdwn', text: lines.join('\\n') } },\n    { type: 'actions', elements: [\n      { type: 'button', style: 'primary', text: { type: 'plain_text', text: 'Approve and file' }, url: link('approve') },\n      { type: 'button', text: { type: 'plain_text', text: 'Hold it' }, url: link('hold') },\n    ] },\n  ],\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Approval card",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the approval request",
        "nextElementIds": [
          "89012942-6F43-4FD0-A0D4-8C034D0F07B4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check supplier and order Result"
          },
          "tools": {
            "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listEntities": {
              "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listEntities",
              "dynamicOptionsLabels": {}
            },
            "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listIssuedDocuments": {
              "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listIssuedDocuments",
              "dynamicOptionsLabels": {}
            },
            "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listReceivedDocuments": {
              "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listReceivedDocuments",
              "dynamicOptionsLabels": {}
            }
          },
          "position": {
            "x": 992.4148575158642,
            "y": 389.2625971482744
          }
        },
        "flowElementId": "C5544ABF-C09F-43B6-AA56-131A76A4CE24",
        "groupId": null,
        "id": "25906EF7-EA75-4497-8C92-4D074416242C",
        "metaInfo": {
          "aiApiKey": null,
          "aiModel": "claude-sonnet-5",
          "aiProvider": "ANTHROPIC",
          "clientValidationState": {
            "errorMessage": "Block: 'Check supplier and order', Error: [List Entities] connectionId: OAuth Connection is required",
            "valid": false
          },
          "dynamicAiApiKey": {
            "expression": [
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Anthropic key",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Anthropic key"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "files": [],
          "forceParsedOutput": true,
          "langSmithSettings": {
            "enabled": false,
            "apiKey": null,
            "projectName": null,
            "label": "FlowRunner AI-Agent",
            "accountCluster": "US"
          },
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "messagesHistoryEnabled": false,
          "messagesHistoryLimit": 15,
          "onFailElemId": null,
          "resultAlias": "Invoice check",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You check supplier e-invoices that have just reached Fatture in Cloud, before they are filed as costs. Use the tools:\n1. Find the supplier among the company's suppliers with List Entities, entity kind suppliers. Match on VAT number when the invoice shows one, otherwise on name.\n2. If the supplier is on file, find the supplier order this invoice bills with List Issued Documents, document type supplier_order, for that supplier. Use the order reference in the invoice file when there is one.\n3. Compare the invoice lines and net amount with that order.\n4. Read what this supplier has billed before with List Received Documents for that supplier.\nReply with JSON only, with these fields:\nsupplierId: the supplier's id in Fatture in Cloud, or empty text if the supplier is not on file\nnewSupplier: true if the supplier is not on file\nsupplierVatNumber: the supplier's VAT number from the invoice or the register, or empty text\ninvoiceNumber: the supplier's own invoice number from the invoice file, or empty text\norderNumber: the number of the matching supplier order, or empty text if none matches\nlineDifferences: one sentence on any line or amount that differs from the order, or empty text\nwithinTolerance: true if the invoice's net amount is within the tolerance percent of the order's net amount\naboveHistory: true if the invoice's gross amount is higher than any invoice this supplier has billed before\nclean: true only if newSupplier is false, an order matches, withinTolerance is true and aboveHistory is false\nsummary: one or two plain sentences for the cost center owner saying who billed what and which order it matches"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [
            {
              "connectionId": null,
              "definition": {},
              "enabled": true,
              "hostType": "SHARED",
              "methodName": "listEntities",
              "name": "List Entities",
              "notes": "Lists the clients or suppliers of a Fatture in Cloud company, with filtering, sorting and paging.",
              "packageId": "default",
              "params": [
                {
                  "name": "entityKind",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "companyId",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "filter",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "sort",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "page",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "perPage",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "fields",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "fieldset",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                }
              ],
              "serviceId": "fatture-in-cloud",
              "type": "FR_FUNCTION"
            },
            {
              "connectionId": null,
              "definition": {},
              "enabled": true,
              "hostType": "SHARED",
              "methodName": "listIssuedDocuments",
              "name": "List Issued Documents",
              "notes": "Lists the documents a Fatture in Cloud company has issued: invoices, quotes, proformas, receipts, delivery notes, credit notes, orders, work reports, supplier orders and self invoices.",
              "packageId": "default",
              "params": [
                {
                  "name": "documentType",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "companyId",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "entityId",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "dateFrom",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "dateTo",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "filter",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "sort",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "page",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "perPage",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "fields",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "fieldset",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                }
              ],
              "serviceId": "fatture-in-cloud",
              "type": "FR_FUNCTION"
            },
            {
              "connectionId": null,
              "definition": {},
              "enabled": true,
              "hostType": "SHARED",
              "methodName": "listReceivedDocuments",
              "name": "List Received Documents",
              "notes": "Lists the documents a Fatture in Cloud company has received: supplier invoices, passive credit notes, delivery notes and self invoices.",
              "packageId": "default",
              "params": [
                {
                  "name": "documentType",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "companyId",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "entityId",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "dateFrom",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "dateTo",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "filter",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "sort",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "page",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "perPage",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "fields",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "fieldset",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                }
              ],
              "serviceId": "fatture-in-cloud",
              "type": "FR_FUNCTION"
            }
          ],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "A new supplier e-invoice is waiting in Fatture in Cloud.\nSupplier: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "supplier_name",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nDate: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "date",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nNet: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "amount_net",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", VAT: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "amount_vat",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", gross: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "amount_gross",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nCost center: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "cost_center",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nTolerance: "
              },
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Price tolerance percent",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Price tolerance percent"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " percent\n\nPending record:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Supplier invoice",
                "subPathSegments": [
                  {
                    "key": "asText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nInvoice file:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Invoice file",
                "subPathSegments": [
                  {
                    "key": "text",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "E9793408-8AEF-4294-BE06-2B6C52E72636"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Check supplier and order",
        "nextElementIds": [
          "4E2F3BB3-F5A7-4E76-9DA8-A46F9DD741B0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Confirm the hold Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": -54.251572876822905,
            "y": 1038.5855125727999
          }
        },
        "flowElementId": "5067DFC3-8458-4F7E-B6E7-C4A8F0F6CA55",
        "groupId": null,
        "id": "25608A38-2739-4029-9BDA-EEEE43022CA4",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Held. The invoice from "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "supplier_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " stays in the pending queue in Fatture in Cloud and was not filed."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Approval question",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "89012942-6F43-4FD0-A0D4-8C034D0F07B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "COMPLEX_LIST",
              "value": []
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Hold note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Confirm the hold",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 225.33871949322167,
            "y": 861.8153756399945
          }
        },
        "flowElementId": "8E62C035-DADC-468B-B209-60D71A561576",
        "groupId": null,
        "id": "C8576051-23B5-420E-95C0-3C1D229D38AE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "485b0f70-41aa-44cc-9964-76bb87645a2f",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Owner decision",
                      "subPathSegments": [
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "17A750B4-3CAE-40FF-9337-E04034487D9A"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "approve"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "485b0f70-41aa-44cc-9964-76bb87645a2f"
            ]
          },
          "elseComponent": {
            "componentId": "25608A38-2739-4029-9BDA-EEEE43022CA4",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Approved",
          "storeResult": false,
          "thenComponent": {
            "componentId": "2198B57A-D9A3-4CE1-B24A-19D6AE4ACCD2",
            "componentType": "ELEMENT"
          }
        },
        "name": "Approved?",
        "nextElementIds": [
          "25608A38-2739-4029-9BDA-EEEE43022CA4",
          "2198B57A-D9A3-4CE1-B24A-19D6AE4ACCD2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 437.83117970869034,
            "y": 1040.1379209758556
          }
        },
        "flowElementId": "B22EDE23-6415-40F1-ADDB-D481BBA2440F",
        "groupId": null,
        "id": "2198B57A-D9A3-4CE1-B24A-19D6AE4ACCD2",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "af60c7f7-c256-4395-a825-2bc311ca4a4e",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Invoice check",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "newSupplier",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "af60c7f7-c256-4395-a825-2bc311ca4a4e"
            ]
          },
          "elseComponent": {
            "componentId": "EBA4DC33-C612-4765-B364-C162266E0895",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "New supplier check",
          "storeResult": false,
          "thenComponent": {
            "componentId": "DBB197A8-931E-4E96-AAD6-7F45F490AAD6",
            "componentType": "ELEMENT"
          }
        },
        "name": "New supplier?",
        "nextElementIds": [
          "EBA4DC33-C612-4765-B364-C162266E0895",
          "DBB197A8-931E-4E96-AAD6-7F45F490AAD6"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Lists the electronic invoices that have reached a Fatture in Cloud company and are waiting to be accepted into its accounts.",
          "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listPendingReceivedDocuments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List the pending invoices Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::listPendingReceivedDocuments",
          "legacyElementId": "JS###v1###FattureInCloudService###listPendingReceivedDocuments",
          "methodName": "listPendingReceivedDocuments",
          "position": {
            "x": 400,
            "y": 200
          }
        },
        "flowElementId": "D81D3E32-3A69-49C3-B35B-F0069D1EE2DF",
        "groupId": null,
        "id": "34BF087E-01D7-4329-ABF7-360EC452356C",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "page",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "perPage",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 100
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'List the pending invoices', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listPendingReceivedDocuments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Pending invoices",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fatture-in-cloud",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List the pending invoices",
        "nextElementIds": [
          "51251C64-89C7-421A-9A55-00F0E7A078D1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a client or supplier in a Fatture in Cloud company.",
          "elementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::createEntity",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Add the supplier Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fatture-in-cloud:::createEntity",
          "legacyElementId": "JS###v1###FattureInCloudService###createEntity",
          "methodName": "createEntity",
          "position": {
            "x": 819.7587268949954,
            "y": 1032.6303811913242
          }
        },
        "flowElementId": "CB8511A8-ADF6-4437-B37E-D256BBA41464",
        "groupId": null,
        "id": "DBB197A8-931E-4E96-AAD6-7F45F490AAD6",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "name",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "supplier_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "entityKind",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "suppliers"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "type",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "company"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "code",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "vatNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "supplierVatNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "taxCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "certifiedEmail",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "eInvoiceCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "eInvoice",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phone",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "street",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "postalCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "city",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "province",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "countryIso",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "defaultPaymentTerms",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bankIban",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "notes",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Add the supplier', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createEntity",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New supplier",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fatture-in-cloud",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Add the supplier",
        "nextElementIds": [
          "EBA4DC33-C612-4765-B364-C162266E0895"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Fetch the invoice file Result"
          },
          "position": {
            "x": 1034.07502775665,
            "y": 213.74406955481516
          }
        },
        "flowElementId": "8574D995-F390-4FBF-A1A1-3A50D69C8D9F",
        "groupId": null,
        "id": "E9793408-8AEF-4294-BE06-2B6C52E72636",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "attachment_url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "filename",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "filename",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pendingId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "if (!fileUrl) throw new Error('The pending e-invoice has no file attached.');\nconst res = await fetch(fileUrl);\nif (!res.ok) throw new Error(`Could not download the invoice file (HTTP ${res.status}).`);\nconst buf = Buffer.from(await res.arrayBuffer());\nconst name = filename || `supplier-invoice-${pendingId}.xml`;\nconst isXml = /\\.xml(\\.p7m)?$/i.test(name);\nreturn { filename: name, content: buf.toString('base64'), text: isXml ? buf.toString('utf8').slice(0, 60000) : '' };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Invoice file",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Fetch the invoice file",
        "nextElementIds": [
          "25906EF7-EA75-4497-8C92-4D074416242C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Note it for the cost center owner Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1166.8308096200253,
            "y": 1128.1629302280721
          }
        },
        "flowElementId": "C2AF92E4-49CD-465D-B5E4-BEE5DF255BCB",
        "groupId": null,
        "id": "81ED7796-5BBC-405D-B1C8-5B86322A6731",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Filed in Fatture in Cloud: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "supplier_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Supplier invoice",
                    "subPathSegments": [
                      {
                        "key": "amount_gross",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "51251C64-89C7-421A-9A55-00F0E7A078D1"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " gross, with the invoice file attached. "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice check",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "summary",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "COMPLEX_LIST",
              "value": []
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Record note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Note it for the cost center owner",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Pick out the new invoice Result"
          },
          "position": {
            "x": 690,
            "y": 200
          }
        },
        "flowElementId": "6D0C5AF1-D947-43D6-A84B-C5D9E1B1BA7D",
        "groupId": null,
        "id": "51251C64-89C7-421A-9A55-00F0E7A078D1",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "pending",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Pending invoices",
                    "subPathSegments": [
                      {
                        "key": "data",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "34BF087E-01D7-4329-ABF7-360EC452356C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pendingId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New e-invoice",
                    "subPathSegments": [
                      {
                        "key": "data",
                        "optional": false
                      },
                      {
                        "key": "ids",
                        "optional": false
                      },
                      {
                        "index": 0,
                        "last": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "7DA0D839-F686-4B03-8B0B-343821C0DF77"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = Array.isArray(pending) ? pending : [];\nconst doc = list.find(d => d && String(d.id) === String(pendingId));\nif (!doc) throw new Error(`The new e-invoice (pending id ${pendingId}) is not among the first 100 pending documents.`);\nreturn { ...doc, asText: JSON.stringify(doc) };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Supplier invoice",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Pick out the new invoice",
        "nextElementIds": [
          "E9793408-8AEF-4294-BE06-2B6C52E72636"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 674.9720457161644,
            "y": 403.6826045500476
          }
        },
        "flowElementId": "6DDCC838-0639-45FE-A332-04FE586077B4",
        "groupId": null,
        "id": "4E2F3BB3-F5A7-4E76-9DA8-A46F9DD741B0",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "a1c237c4-7681-4974-9664-f70152e2fe26",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Invoice check",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "clean",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "25906EF7-EA75-4497-8C92-4D074416242C"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "a1c237c4-7681-4974-9664-f70152e2fe26"
            ]
          },
          "elseComponent": {
            "componentId": "BCB6729B-D8EB-43D9-9DB5-991EB877C7A5",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Clean match",
          "storeResult": false,
          "thenComponent": {
            "componentId": "EBA4DC33-C612-4765-B364-C162266E0895",
            "componentType": "ELEMENT"
          }
        },
        "name": "Clean match?",
        "nextElementIds": [
          "EBA4DC33-C612-4765-B364-C162266E0895",
          "BCB6729B-D8EB-43D9-9DB5-991EB877C7A5"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 207.51635920169252,
            "y": 706.8002960709314
          }
        },
        "flowElementId": "DC8ACC42-9A15-478F-8346-BF4605735145",
        "groupId": null,
        "id": "17A750B4-3CAE-40FF-9337-E04034487D9A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Owner decision",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Wait for the owner's answer",
        "nextElementIds": [
          "C8576051-23B5-420E-95C0-3C1D229D38AE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      }
    ],
    "firstElementId": "7DA0D839-F686-4B03-8B0B-343821C0DF77",
    "groups": [],
    "id": "32740E42-BA36-4B72-AF41-2DF20A2E9E89",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [
        {
          "description": "The Anthropic key the AI step uses.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "The URL of the block Wait for the owner's answer. The Slack buttons open it.",
          "error": null,
          "name": "Answer link",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "How far, in percent, an invoice's net amount may differ from its supplier order and still be filed without asking.",
          "error": null,
          "name": "Price tolerance percent",
          "type": "INT",
          "value": ""
        }
      ],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-11-17T05:54:39.352Z"
}
