{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "B9C13363-5BE6-4887-9B19-8CB27F732A72",
    "name": "weclapp: weekly overdue invoice reminders"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": 136,
        "y": -21,
        "zoom": 1
      },
      "autoSave": true,
      "descriptions": {
        "flow": "Each week, finds open weclapp invoices past their due date. Recent ones get a reminder email with the invoice PDF attached. Invoices past the controller's limit, or with no customer email, go to the controller in Slack with the PDF, the dunning state and the customer's other open invoices.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Each week, finds open weclapp invoices past their due date. Recent ones get a reminder email with the invoice PDF attached. Invoices past the controller's limit, or with no customer email, go to the controller in Slack with the PDF, the dunning state and the customer's other open invoices.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Downloads the most recently generated PDF document of a sales invoice and stores it in FlowRunner file storage, returning a URL that later steps can email to the customer or archive. The invoice must already have a generated document, which normally means its status is DOCUMENT_CREATED or later.",
          "elementId": "EXTENSION:::SHARED:::default:::weclapp:::downloadSalesInvoicePdf",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Download the invoice PDF Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::weclapp:::downloadSalesInvoicePdf",
          "legacyElementId": "JS###v1###Weclapp###downloadSalesInvoicePdf",
          "methodName": "downloadSalesInvoicePdf",
          "position": {
            "x": 690,
            "y": 130
          }
        },
        "flowElementId": "C19C924B-127D-4031-8CEF-D2D3388A4522",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "3D87EA50-47FC-42DD-A540-735F6D0901A1",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "salesInvoiceId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  }
                ],
                "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": "downloadSalesInvoicePdf",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Invoice PDF",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "weclapp",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Download the invoice PDF",
        "nextElementIds": [
          "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a single sales invoice by its weclapp identifier, including all invoice items, shipping cost items, the linked sales orders, addresses, and payment and dunning state.",
          "elementId": "EXTENSION:::SHARED:::default:::weclapp:::getSalesInvoice",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Load the invoice Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::weclapp:::getSalesInvoice",
          "legacyElementId": "JS###v1###Weclapp###getSalesInvoice",
          "methodName": "getSalesInvoice",
          "position": {
            "x": 110,
            "y": 130
          }
        },
        "flowElementId": "67081595-8FDE-4D01-8A73-D62505CE9FB3",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "salesInvoiceId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218"
                  }
                ],
                "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": "getSalesInvoice",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Invoice",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "weclapp",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Load the invoice",
        "nextElementIds": [
          "B3BC2000-C53D-4EED-986A-F2ABF4390265"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends emails through Gmail for AI agents to automate customer communication.",
          "elementId": "EXTENSION:::SHARED:::default:::gmail-service:::sendMessage",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Email the customer a reminder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::gmail-service:::sendMessage",
          "legacyElementId": "JS###v1###GmailService###sendMessage",
          "methodName": "sendMessage",
          "position": {
            "x": 948.9883117731664,
            "y": 484.3721368922427
          }
        },
        "flowElementId": "30DA3021-8F6A-4257-9702-8FA7CE27CB93",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "59B382E8-5781-4042-8A44-1A516AB953E4",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "to",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Payment reminder: invoice "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": [
                      {
                        "key": "invoiceNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bodyType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "plain"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bodyContent",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Hello,\n\nInvoice "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": [
                      {
                        "key": "invoiceNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " for "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lateness",
                    "subPathSegments": [
                      {
                        "key": "amountText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B3BC2000-C53D-4EED-986A-F2ABF4390265"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " was due on "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lateness",
                    "subPathSegments": [
                      {
                        "key": "dueDateText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B3BC2000-C53D-4EED-986A-F2ABF4390265"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " and is still open in our records. A copy is attached.\n\nIf you have already paid it, please reply with the payment date so we can match it.\n\nThank you"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "from",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cc",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bcc",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "attachments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice PDF",
                    "subPathSegments": [
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3D87EA50-47FC-42DD-A540-735F6D0901A1"
                  }
                ],
                "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": "sendMessage",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Reminder email",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "gmail-service",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Email the customer a reminder",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a single party by its weclapp identifier, returning the complete record including addresses, bank accounts, contacts, role flags, and the version used for optimistic locking. Use this before updating a party so no unknown property is overwritten.",
          "elementId": "EXTENSION:::SHARED:::default:::weclapp:::getParty",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Load the customer Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::weclapp:::getParty",
          "legacyElementId": "JS###v1###Weclapp###getParty",
          "methodName": "getParty",
          "position": {
            "x": 980,
            "y": 130
          }
        },
        "flowElementId": "E62DB4EA-F4C6-40D4-A149-E07AD7A0FDA7",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "1B824609-4071-4B66-B3D3-C7D0FD6DB849",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "partyId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": [
                      {
                        "key": "customerId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  }
                ],
                "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": "getParty",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Customer",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "weclapp",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Load the customer",
        "nextElementIds": [
          "5E8B3713-FD5E-41A9-8D39-09514ADDB60B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 981.244564743173,
            "y": 292.53299948587863
          }
        },
        "flowElementId": "D203B35F-AA56-4C35-9BD2-20F852E2C6C5",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "5E8B3713-FD5E-41A9-8D39-09514ADDB60B",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "47ab0866-e9af-4dca-b06c-8af5178a1ed7",
                "nestedOperation": null,
                "operation": ">",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Lateness",
                      "subPathSegments": [
                        {
                          "key": "daysOverdue",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "B3BC2000-C53D-4EED-986A-F2ABF4390265"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "PLACEHOLDER_DATA",
                        "label": "Controller after days",
                        "subPathSegments": null,
                        "type": "EXECUTION_CONTEXT_STATIC_DATA",
                        "value": "Controller after days"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              },
              {
                "id": "0beb63b0-9c3d-410c-9db2-0a944e5f5c55",
                "nestedOperation": null,
                "operation": "isEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Customer",
                      "subPathSegments": [
                        {
                          "key": "email",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "47ab0866-e9af-4dca-b06c-8af5178a1ed7",
              "OR",
              "0beb63b0-9c3d-410c-9db2-0a944e5f5c55"
            ]
          },
          "elseComponent": {
            "componentId": "59B382E8-5781-4042-8A44-1A516AB953E4",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Controller call",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C70A8EF2-8F3E-46C4-9654-0A5ABCE7460A",
            "componentType": "ELEMENT"
          }
        },
        "name": "Controller's call?",
        "nextElementIds": [
          "59B382E8-5781-4042-8A44-1A516AB953E4",
          "C70A8EF2-8F3E-46C4-9654-0A5ABCE7460A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Lists sales invoices with their document status, payment status, invoice and due dates, and calculated totals. Filtering by payment status Open together with a due date cutoff is the usual way to build an overdue receivables list.",
          "elementId": "EXTENSION:::SHARED:::default:::weclapp:::listSalesInvoices",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the customer's other open invoices Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::weclapp:::listSalesInvoices",
          "legacyElementId": "JS###v1###Weclapp###listSalesInvoices",
          "methodName": "listSalesInvoices",
          "position": {
            "x": 464.8474622407617,
            "y": 287.43390404201347
          }
        },
        "flowElementId": "B75E8882-6380-4F66-AE25-FB267165F1D0",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "C70A8EF2-8F3E-46C4-9654-0A5ABCE7460A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "paymentStatus",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "OPEN"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customerId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": [
                      {
                        "key": "customerId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceDateFrom",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceDateTo",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueBefore",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "page",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 100
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "dueDate"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "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": "listSalesInvoices",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Other open invoices",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "weclapp",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the customer's other open invoices",
        "nextElementIds": [
          "C530E258-FE09-4A4A-8094-AFB21C39536A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the controller's brief Result"
          },
          "tools": {},
          "position": {
            "x": 62.13700565533463,
            "y": 283.9757551167819
          }
        },
        "flowElementId": "29DFAAE8-991B-42D3-97D8-6F467E7B5264",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "C530E258-FE09-4A4A-8094-AFB21C39536A",
        "metaInfo": {
          "aiApiKey": null,
          "aiModel": "claude-sonnet-5",
          "aiProvider": "ANTHROPIC",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "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": false,
          "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": "Controller brief",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You brief a controller on an overdue customer invoice so they can decide how to approach the customer. Write a short Slack message in plain text, no more than 8 lines: the customer, the invoice number, amount and due date, how many days it is overdue, the payment and dunning state from the invoice record (reminders or dunning levels already sent and when, if the record shows them), and the customer's other open invoices with their amounts and due dates. If the customer has no email address in weclapp, say so. Do not recommend an action and do not invent anything the records do not show."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Customer: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "company",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "firstName",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "lastName",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", customer number "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "customerNumber",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", email "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "email",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "1B824609-4071-4B66-B3D3-C7D0FD6DB849"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nDays overdue: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Lateness",
                "subPathSegments": [
                  {
                    "key": "daysOverdue",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "B3BC2000-C53D-4EED-986A-F2ABF4390265"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nAmount: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Lateness",
                "subPathSegments": [
                  {
                    "key": "amountText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "B3BC2000-C53D-4EED-986A-F2ABF4390265"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", due "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Lateness",
                "subPathSegments": [
                  {
                    "key": "dueDateText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "B3BC2000-C53D-4EED-986A-F2ABF4390265"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nInvoice record:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Invoice",
                "subPathSegments": null,
                "type": "ELEMENT_LINK",
                "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nThe customer's open invoices, including this one:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Other open invoices",
                "subPathSegments": null,
                "type": "ELEMENT_LINK",
                "value": "C70A8EF2-8F3E-46C4-9654-0A5ABCE7460A"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Write the controller's brief",
        "nextElementIds": [
          "EF0D7C6C-5DE8-4B34-A991-3CCE7F46152F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Work out how late it is Result"
          },
          "position": {
            "x": 400,
            "y": 130
          }
        },
        "flowElementId": "BD9F93C1-6366-45EF-A802-818B9D0DDD2F",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "B3BC2000-C53D-4EED-986A-F2ABF4390265",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "dueDate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "dueDate",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "grossAmount",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "grossAmount",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoice",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const due = Number(dueDate);\nconst daysOverdue = Math.max(0, Math.floor((Date.now() - due) / 86400000));\nconst currency = (invoice && invoice.recordCurrencyName) || '';\nconst amount = (invoice && invoice.grossAmount) || grossAmount || '';\nreturn {\n  daysOverdue,\n  dueDateText: new Date(due).toISOString().slice(0, 10),\n  amountText: currency ? `${amount} ${currency}` : String(amount),\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Lateness",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Work out how late it is",
        "nextElementIds": [
          "3D87EA50-47FC-42DD-A540-735F6D0901A1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists sales invoices with their document status, payment status, invoice and due dates, and calculated totals. Filtering by payment status Open together with a due date cutoff is the usual way to build an overdue receivables list.",
          "elementId": "EXTENSION:::SHARED:::default:::weclapp:::listSalesInvoices",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find overdue open invoices Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::weclapp:::listSalesInvoices",
          "legacyElementId": "JS###v1###Weclapp###listSalesInvoices",
          "methodName": "listSalesInvoices",
          "position": {
            "x": 110,
            "y": 310
          }
        },
        "flowElementId": "8B7115C2-048A-4A8E-B005-6BF1D9597023",
        "groupId": null,
        "id": "AEDA2853-E837-4E6A-9EA8-12A6FA28DE72",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "paymentStatus",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "OPEN"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceDateFrom",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "invoiceDateTo",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueBefore",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "GET_CURRENT_DATE",
                    "label": null,
                    "type": "GET_CURRENT_DATE_TIME",
                    "value": null
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "page",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1000
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "dueDate"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "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": "listSalesInvoices",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Overdue invoices",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "weclapp",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find overdue open invoices",
        "nextElementIds": [],
        "nextGroupIds": [
          "25DC9BBB-86CF-47BC-BD07-6A0136C3B218"
        ],
        "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": "Hand it to the controller Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 103.15028303866941,
            "y": 503.5682118689797
          }
        },
        "flowElementId": "D7C5393E-35C9-4A7F-B48A-AF99E1445F2F",
        "groupId": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "id": "EF0D7C6C-5DE8-4B34-A991-3CCE7F46152F",
        "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": "*Overdue invoice "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice",
                    "subPathSegments": [
                      {
                        "key": "invoiceNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " needs your call.* No automated reminder was sent.\n"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Controller brief",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C530E258-FE09-4A4A-8094-AFB21C39536A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\n<"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice PDF",
                    "subPathSegments": [
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3D87EA50-47FC-42DD-A540-735F6D0901A1"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "|Open the invoice PDF>"
                  }
                ],
                "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": "BASIC",
                "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": "Controller handoff",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Hand it to the controller",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "AEDA2853-E837-4E6A-9EA8-12A6FA28DE72",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": 364.5813341408091,
            "y": 102.5925243472546,
            "zoom": 0.5783440919526437
          },
          "position": {
            "x": 412,
            "y": 317
          }
        },
        "flowElementId": "2EB39B19-1D2A-4DBE-9B57-A6DDB395894F",
        "groupId": null,
        "id": "25DC9BBB-86CF-47BC-BD07-6A0136C3B218",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "enabled": true,
          "firstElementId": "33AD562F-43EB-4D42-AFA7-D07A2C5DE4CA",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Overdue invoices",
                "subPathSegments": null,
                "type": "ELEMENT_LINK",
                "value": "AEDA2853-E837-4E6A-9EA8-12A6FA28DE72"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "Invoice loop",
          "storeResult": true
        },
        "name": "For each overdue invoice",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "FF68ADB6-8A9A-46F2-95E0-1BFB63E3BEE2",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [
        {
          "description": "Your Anthropic API key, used to write the controller's brief.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "Invoices more days overdue than this go to the controller instead of getting another automated reminder.",
          "error": null,
          "name": "Controller after days",
          "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:55:58.012Z"
}
