{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "F47A4AE4-13F6-4821-83D0-04BD73F67527",
    "name": "Captain: new Box files indexed"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -32.26654152979822,
        "y": 13.721257625527919,
        "zoom": 0.66
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a file is uploaded to a watched Box folder, downloads it, checks Captain for an earlier version by Box file ID, and indexes it into the collection with the Box file ID, folder and uploader as metadata. When an earlier version exists, asks the folder owner in Slack whether to replace it or index the new file beside it.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a file is uploaded to a watched Box folder, downloads it, checks Captain for an earlier version by Box file ID, and indexes it into the collection with the Box file ID, folder and uploader as metadata. When an earlier version exists, asks the folder owner in Slack whether to replace it or index the new file beside it.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Downloads a file from a URL (such as a file from an earlier step) and uploads it into a collection. Indexing runs in the background: the action returns the job ID, and the On Indexing Job Completed trigger or Get Job Status reports the outcome.",
          "elementId": "EXTENSION:::SHARED:::default:::captain:::indexFile",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Index the file Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::captain:::indexFile",
          "legacyElementId": null,
          "methodName": "indexFile",
          "position": {
            "x": 1961,
            "y": 40
          }
        },
        "flowElementId": "F46880DB-39C8-4459-AEBB-B60E0210F7CB",
        "groupId": null,
        "id": "3A306897-58A3-4FC1-AEE0-E63EAE7CC9F0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "collectionName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Captain collection",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Captain collection"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "downloadUrl",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "fileName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "processingType",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replaceExisting",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customMetadata",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "{\"box_file_id\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\", \"box_folder\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "folderName",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\", \"uploaded_by\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "createdBy",
                        "optional": false
                      },
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\"}"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": true,
                "resultType": null
              }
            },
            {
              "name": "transcriptionLanguage",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maskPii",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "piiInstructions",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "idempotencyKey",
              "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": "indexFile",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Index job",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "captain",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Index the file",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 802,
            "y": 219
          }
        },
        "flowElementId": "C919F330-475E-4D87-9893-F50A8D8596A5",
        "groupId": null,
        "id": "BD7A6F0F-309C-449B-8AD9-6D2B31017A51",
        "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 folder owner's answer",
        "nextElementIds": [
          "3652B120-F41F-4CBC-BD5E-DD8B9E1DA5D6"
        ],
        "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 folder owner Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1216,
            "y": 210
          }
        },
        "flowElementId": "108E478F-7AC6-4D68-B291-BE52D69BC11B",
        "groupId": null,
        "id": "7797DD4C-3083-4D38-BEB9-B29DB5B36146",
        "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": "Question card",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "057E1840-46A7-4C0A-82C3-9016D8871EDA"
                  }
                ],
                "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": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Question card",
                    "subPathSegments": [
                      {
                        "key": "blocks",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "057E1840-46A7-4C0A-82C3-9016D8871EDA"
                  }
                ],
                "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": "Question to owner",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask the folder owner",
        "nextElementIds": [
          "BD7A6F0F-309C-449B-8AD9-6D2B31017A51"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a Box file's contents and saves them to FlowRunner file storage, returning the saved file's URL. Box redirects to its download host, which this action follows automatically. The content type comes from the download's Content-Type header, falling back to the file name's extension. An empty download for a file Box reports as non-empty is rejected as an error.",
          "elementId": "EXTENSION:::SHARED:::default:::box:::downloadFile",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Download the file Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::box:::downloadFile",
          "legacyElementId": "JS###v1###Box###downloadFile",
          "methodName": "downloadFile",
          "position": {
            "x": 850,
            "y": 40
          }
        },
        "flowElementId": "DEAAB666-D913-4684-B71F-E9E3DC495A95",
        "groupId": null,
        "id": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "fileId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Download the 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": "downloadFile",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Downloaded file",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "box",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Download the file",
        "nextElementIds": [
          "7B1855C0-10A5-4FE6-9163-0C781AA20400"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a file from a URL (such as a file from an earlier step) and uploads it into a collection. Indexing runs in the background: the action returns the job ID, and the On Indexing Job Completed trigger or Get Job Status reports the outcome.",
          "elementId": "EXTENSION:::SHARED:::default:::captain:::indexFile",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Index the new file beside it Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::captain:::indexFile",
          "legacyElementId": null,
          "methodName": "indexFile",
          "position": {
            "x": 110,
            "y": 210
          }
        },
        "flowElementId": "22EFBFA4-259E-40C1-9846-E1FDD97F8725",
        "groupId": null,
        "id": "B8BC6ED3-88F9-4002-B44D-6FF01D7E545A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "collectionName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Captain collection",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Captain collection"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "downloadUrl",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "fileName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "processingType",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replaceExisting",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customMetadata",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "{\"box_file_id\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\", \"box_folder\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "folderName",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\", \"uploaded_by\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "createdBy",
                        "optional": false
                      },
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\"}"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": true,
                "resultType": null
              }
            },
            {
              "name": "transcriptionLanguage",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maskPii",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "piiInstructions",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "idempotencyKey",
              "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": "indexFile",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Beside job",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "captain",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Index the new file beside it",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when a chosen Box folder changes (created, renamed, moved, deleted, or a file is uploaded into it). Box registers a webhook on the folder and this trigger runs your flow when the event arrives.",
          "elementId": "EXTENSION:::SHARED:::default:::box:::onFolderEvent",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::box:::onFolderEvent",
          "legacyElementId": "JS###v1###Box###onFolderEvent",
          "methodName": "onFolderEvent",
          "position": {
            "x": 462,
            "y": 40
          }
        },
        "flowElementId": "D302DE60-4726-443F-9F7B-D59FD5E68718",
        "groupId": null,
        "id": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": "Block: 'New file in the Box folder', Error: OAuth Connection is required",
            "valid": false
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onFolderEvent",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New file",
          "scope": "SINGLE_APP",
          "serviceId": "box",
          "slaConditions": [],
          "staticData": {
            "folderId": "0",
            "event": "FILE.UPLOADED"
          },
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New file in the Box folder",
        "nextElementIds": [
          "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Lists the documents in a collection, a page at a time. A metadata filter finds the document that carries an ID from your own system.",
          "elementId": "EXTENSION:::SHARED:::default:::captain:::listDocuments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Look for an earlier version Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::captain:::listDocuments",
          "legacyElementId": null,
          "methodName": "listDocuments",
          "position": {
            "x": 1198,
            "y": 40
          }
        },
        "flowElementId": "D3912834-0004-4D93-8188-C008B7475063",
        "groupId": null,
        "id": "7B1855C0-10A5-4FE6-9163-0C781AA20400",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "collectionName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Captain collection",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Captain collection"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "metadataFilter",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "{\"box_file_id\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\"}"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": true,
                "resultType": null
              }
            },
            {
              "name": "includeCustomMetadata",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 5
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "offset",
              "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": "listDocuments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Earlier versions",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "captain",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Look for an earlier version",
        "nextElementIds": [
          "A3F52A68-64C9-470A-89AD-8DE356CA060D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1580,
            "y": 49
          }
        },
        "flowElementId": "4F4FAE6D-B9EC-461B-9CCD-C5D31BCE582C",
        "groupId": null,
        "id": "A3F52A68-64C9-470A-89AD-8DE356CA060D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "680c752e-0283-4d90-b48c-c9ba10c6b108",
                "nestedOperation": null,
                "operation": ">",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Earlier versions",
                      "subPathSegments": [
                        {
                          "key": "total_count",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "7B1855C0-10A5-4FE6-9163-0C781AA20400"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "NUMBER",
                        "label": null,
                        "type": "INPUT",
                        "value": 0
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "680c752e-0283-4d90-b48c-c9ba10c6b108"
            ]
          },
          "elseComponent": {
            "componentId": "3A306897-58A3-4FC1-AEE0-E63EAE7CC9F0",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Earlier version check",
          "storeResult": false,
          "thenComponent": {
            "componentId": "057E1840-46A7-4C0A-82C3-9016D8871EDA",
            "componentType": "ELEMENT"
          }
        },
        "name": "Earlier version in Captain?",
        "nextElementIds": [
          "3A306897-58A3-4FC1-AEE0-E63EAE7CC9F0",
          "057E1840-46A7-4C0A-82C3-9016D8871EDA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 453,
            "y": 219
          }
        },
        "flowElementId": "E7CB4F42-8D8B-4DB2-B639-D44D20089072",
        "groupId": null,
        "id": "3652B120-F41F-4CBC-BD5E-DD8B9E1DA5D6",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "442f971f-8a78-4419-bc3c-9ddcc389a414",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Owner decision",
                      "subPathSegments": [
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "BD7A6F0F-309C-449B-8AD9-6D2B31017A51"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "replace"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "442f971f-8a78-4419-bc3c-9ddcc389a414"
            ]
          },
          "elseComponent": {
            "componentId": "B8BC6ED3-88F9-4002-B44D-6FF01D7E545A",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Replace check",
          "storeResult": false,
          "thenComponent": {
            "componentId": "30E2AF5C-6018-4A4D-B8DE-6E910BFEAC30",
            "componentType": "ELEMENT"
          }
        },
        "name": "Replace the earlier version?",
        "nextElementIds": [
          "B8BC6ED3-88F9-4002-B44D-6FF01D7E545A",
          "30E2AF5C-6018-4A4D-B8DE-6E910BFEAC30"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a file from a URL (such as a file from an earlier step) and uploads it into a collection. Indexing runs in the background: the action returns the job ID, and the On Indexing Job Completed trigger or Get Job Status reports the outcome.",
          "elementId": "EXTENSION:::SHARED:::default:::captain:::indexFile",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Replace the earlier version Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::captain:::indexFile",
          "legacyElementId": null,
          "methodName": "indexFile",
          "position": {
            "x": 457,
            "y": 380
          }
        },
        "flowElementId": "C8A96C3C-1BB5-46BA-8C0A-1BE8A784C340",
        "groupId": null,
        "id": "30E2AF5C-6018-4A4D-B8DE-6E910BFEAC30",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "collectionName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Captain collection",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Captain collection"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "downloadUrl",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "fileName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "processingType",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replaceExisting",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customMetadata",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "{\"box_file_id\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\", \"box_folder\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "folderName",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\", \"uploaded_by\": \""
                  },
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "createdBy",
                        "optional": false
                      },
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\"}"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": true,
                "resultType": null
              }
            },
            {
              "name": "transcriptionLanguage",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maskPii",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "piiInstructions",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "idempotencyKey",
              "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": "indexFile",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Replace job",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "captain",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Replace the earlier version",
        "nextElementIds": [],
        "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 question for the folder owner Result"
          },
          "position": {
            "x": 1536,
            "y": 219
          }
        },
        "flowElementId": "BA3FAF10-7904-42E1-B4BF-D5844431B1B3",
        "groupId": null,
        "id": "057E1840-46A7-4C0A-82C3-9016D8871EDA",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Downloaded file",
                    "subPathSegments": [
                      {
                        "key": "fileName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "28E7456E-A0EE-41F6-97DC-EBEDBB69239F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "folderName",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "uploader",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New file",
                    "subPathSegments": [
                      {
                        "key": "createdBy",
                        "optional": false
                      },
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "earlier",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Earlier versions",
                    "subPathSegments": [
                      {
                        "key": "documents",
                        "optional": false
                      },
                      {
                        "index": 0,
                        "last": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7B1855C0-10A5-4FE6-9163-0C781AA20400"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "earlierCount",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Earlier versions",
                    "subPathSegments": [
                      {
                        "key": "total_count",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7B1855C0-10A5-4FE6-9163-0C781AA20400"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "collection",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Captain collection",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Captain collection"
                  }
                ],
                "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 link = (decision) => `${answerLink}?execution=${encodeURIComponent(executionId)}&decision=${decision}`;\nconst old = earlier || {};\nconst indexedAt = old.indexed_at ? String(old.indexed_at).slice(0, 10) : 'an unknown date';\nconst count = Number(earlierCount) || 0;\nconst lines = [\n  `*${fileName} was uploaded to ${folderName} in Box by ${uploader}, and Captain already holds an earlier version.*`,\n  `In ${collection}: ${old.filename || fileName}, indexed ${indexedAt}${old.chunk_count ? `, ${old.chunk_count} passages` : ''}${count > 1 ? ` (${count} earlier documents carry this Box file ID)` : ''}.`,\n  'Replace keeps the document ID and swaps in the new content. Index beside it keeps the old version searchable too.',\n];\nreturn {\n  text: `${fileName}: replace the earlier version in Captain, or index it beside the old one?`,\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: 'Replace the earlier version' }, url: link('replace') },\n      { type: 'button', text: { type: 'plain_text', text: 'Index it beside the old one' }, url: link('beside') },\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": "Question card",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the question for the folder owner",
        "nextElementIds": [
          "7797DD4C-3083-4D38-BEB9-B29DB5B36146"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "FCE66714-3F71-4FBF-A4B9-8AA4250FF1E3",
    "groups": [],
    "id": "14363BD8-2A0B-4F7A-A6CA-038587286C07",
    "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 Captain collection the Box folder's files are indexed into, by name.",
          "error": null,
          "name": "Captain collection",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The URL of the block Wait for the folder owner's answer. The Slack buttons open it.",
          "error": null,
          "name": "Answer link",
          "type": "STRING",
          "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-12-02T08:37:42.423Z"
}
