{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "7C1582C1-6E32-4876-B12E-F2DAEECB6331",
    "name": "Captain: indexed files announced in Slack"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -70,
        "y": 0,
        "zoom": 1
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When Captain reports an indexing job completed, reads the job's files and tells the team in Slack which files are now searchable in which collection.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When Captain reports an indexing job completed, reads the job's files and tells the team in Slack which files are now searchable in which collection.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 430,
            "y": 49
          }
        },
        "flowElementId": "B164025F-09D5-45DA-BE09-BAB8BDE5E14F",
        "groupId": null,
        "id": "D370D095-599B-4ED9-A60B-D18610A57564",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "0a60e283-2372-446b-9989-a72b3224e6e0",
                "nestedOperation": null,
                "operation": ">",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Completed job",
                      "subPathSegments": [
                        {
                          "key": "data",
                          "optional": false
                        },
                        {
                          "key": "files",
                          "optional": false
                        },
                        {
                          "key": "indexed",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "86AA1754-03A2-4E8D-BAEC-4AD77E2F9782"
                    }
                  ],
                  "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": [
              "0a60e283-2372-446b-9989-a72b3224e6e0"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "New files check",
          "storeResult": false,
          "thenComponent": {
            "componentId": "1592CBDB-912D-408C-BFF8-F4D537E3BC9F",
            "componentType": "ELEMENT"
          }
        },
        "name": "Any file newly indexed?",
        "nextElementIds": [
          "1592CBDB-912D-408C-BFF8-F4D537E3BC9F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "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": "Tell the team in Slack Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1053,
            "y": 210
          }
        },
        "flowElementId": "605806B6-D9EE-4801-9467-B9325F2CD082",
        "groupId": null,
        "id": "52122FB1-0884-4BFA-B978-1C1DB8548F90",
        "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": "Notice",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "8F3FCA6E-DFA6-4E7E-B8E1-1B345F31B1A3"
                  }
                ],
                "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": [],
                "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": "Team notice",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the team in Slack",
        "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 Slack notice Result"
          },
          "position": {
            "x": 1051,
            "y": 49
          }
        },
        "flowElementId": "59975511-3F3B-488D-978F-7767D07830CF",
        "groupId": null,
        "id": "8F3FCA6E-DFA6-4E7E-B8E1-1B345F31B1A3",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "event",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Completed job",
                    "subPathSegments": [
                      {
                        "key": "data",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "86AA1754-03A2-4E8D-BAEC-4AD77E2F9782"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "job",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Job details",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "1592CBDB-912D-408C-BFF8-F4D537E3BC9F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const files = Array.isArray(job?.files) ? job.files : [];\nconst name = (uri) => {\n  if (!uri) return '(unnamed file)';\n  const s = String(uri);\n  try { return decodeURIComponent(s.split('?')[0].split('/').pop() || s); } catch { return s; }\n};\nconst status = f => String(f.status || f.stage || '').toLowerCase();\nconst indexed = files.filter(f => ['completed', 'indexed', 'processed'].includes(status(f)));\nconst named = indexed.length ? indexed : files;\nconst counts = (event && event.files) || {};\nconst collection = (event && event.collection_name) || job?.collection_name || 'the collection';\nconst meta = job?.custom_metadata || {};\nconst who = meta.uploaded_by ? ` Uploaded by ${meta.uploaded_by}${meta.box_folder ? ` to ${meta.box_folder} in Box` : ''}.` : '';\nconst indexedCount = Number(counts.indexed ?? named.length) || named.length;\nconst lines = [];\nif (named.length === 1) {\n  lines.push(`*${name(named[0].uri)} is now searchable in ${collection}.*${who}`);\n} else {\n  lines.push(`*${indexedCount} files are now searchable in ${collection}.*${who}`);\n  named.slice(0, 15).forEach(f => lines.push(`• ${name(f.uri)}`));\n  if (named.length > 15) lines.push(`and ${named.length - 15} more`);\n}\nconst skipped = Number(counts.skipped) || 0;\nif (skipped) lines.push(`${skipped} unchanged file${skipped === 1 ? ' was' : 's were'} skipped.`);\nreturn { text: lines.join('\\n') };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Notice",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the Slack notice",
        "nextElementIds": [
          "52122FB1-0884-4BFA-B978-1C1DB8548F90"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Returns an indexing job's status, progress, credit usage and per-file results, with a cursor to page through the files.",
          "elementId": "EXTENSION:::SHARED:::default:::captain:::getJob",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the job's files Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::captain:::getJob",
          "legacyElementId": null,
          "methodName": "getJob",
          "position": {
            "x": 751,
            "y": 40
          }
        },
        "flowElementId": "0008B2A4-F8FF-4CF3-AF34-42ADA7974041",
        "groupId": null,
        "id": "1592CBDB-912D-408C-BFF8-F4D537E3BC9F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "jobId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Completed job",
                    "subPathSegments": [
                      {
                        "key": "data",
                        "optional": false
                      },
                      {
                        "key": "job_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "86AA1754-03A2-4E8D-BAEC-4AD77E2F9782"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "filesLimit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 200
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "filesCursor",
              "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": "getJob",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Job details",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "captain",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the job's files",
        "nextElementIds": [
          "8F3FCA6E-DFA6-4E7E-B8E1-1B345F31B1A3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when an indexing job finishes and every file in it was indexed or skipped, so all of it is searchable. Event: job.completed.",
          "elementId": "EXTENSION:::SHARED:::default:::captain:::onJobCompleted",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::captain:::onJobCompleted",
          "legacyElementId": null,
          "methodName": "onJobCompleted",
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "DAAA9620-164E-4E95-A649-5BAA33E8EC02",
        "groupId": null,
        "id": "86AA1754-03A2-4E8D-BAEC-4AD77E2F9782",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onJobCompleted",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Completed job",
          "scope": "SINGLE_APP",
          "serviceId": "captain",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "Indexing job completed",
        "nextElementIds": [
          "D370D095-599B-4ED9-A60B-D18610A57564"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      }
    ],
    "firstElementId": "86AA1754-03A2-4E8D-BAEC-4AD77E2F9782",
    "groups": [],
    "id": "CDABB87B-9913-4837-931A-0788A5B00700",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [],
      "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:31.499Z"
}
