{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "ACBCC128-3FBB-4686-B57A-107C24C8F5D4",
    "name": "ShipStation: new order to label on arrival"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -52.77108433734941,
        "y": -145.54216867469881,
        "zoom": 0.84
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a new order lands in ShipStation, compares live rates across your carriers and buys the cheapest label for the order. A label that costs more than your limits goes to ops in Slack first.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a new order lands in ShipStation, compares live rates across your carriers and buys the cheapest label for the order. A label that costs more than your limits goes to ops in Slack first.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Returns the available shipping rates for the supplied carrier between the supplied origin and destination addresses. Useful for letting customers select shipping options at checkout or for choosing the cheapest service before purchasing a label.",
          "elementId": "EXTENSION:::SHARED:::default:::shipstation:::getShipmentRates",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get this carrier's rates Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::shipstation:::getShipmentRates",
          "legacyElementId": "JS###v1###ShipStation###getShipmentRates",
          "methodName": "getShipmentRates",
          "position": {
            "x": 110,
            "y": 130
          }
        },
        "flowElementId": "420D4BCF-2AEB-4EB3-AA4F-CED80B50AE17",
        "groupId": "930D5A2C-C1C6-4551-BC5E-6E99981E8901",
        "id": "B7426C5B-3AEB-4AA6-BB4A-168998EDD6A7",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "carrierCode",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": null,
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "930D5A2C-C1C6-4551-BC5E-6E99981E8901"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fromPostalCode",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "fromPostalCode",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toPostalCode",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "toPostalCode",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toCountry",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "toCountry",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "serviceCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "packageCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fromCity",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "fromCity",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fromState",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "fromState",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toCity",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "toCity",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toState",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "toState",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "confirmation",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "residential",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Rate request",
                    "subPathSegments": [
                      {
                        "key": "residential",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "weight",
              "type": "OBJECT",
              "value": [
                {
                  "name": "value",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [
                      {
                        "id": "ELEMENT_RESULT",
                        "label": "Rate request",
                        "subPathSegments": [
                          {
                            "key": "weightValue",
                            "optional": false
                          }
                        ],
                        "type": "ELEMENT_LINK",
                        "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                },
                {
                  "name": "units",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [
                      {
                        "id": "ELEMENT_RESULT",
                        "label": "Rate request",
                        "subPathSegments": [
                          {
                            "key": "weightUnits",
                            "optional": false
                          }
                        ],
                        "type": "ELEMENT_LINK",
                        "value": "1713FEF7-6019-4079-ACDD-E03A55F08942"
                      }
                    ],
                    "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": "getShipmentRates",
          "onFailElemId": "7038CDEF-3EA4-4290-817B-8C0242F11EEE",
          "packageId": "default",
          "resultAlias": "Carrier rates",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "shipstation",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get this carrier's rates",
        "nextElementIds": [
          "0D09BC83-896D-4577-9EBE-8C2D8A3F4AE6"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": true,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Rates"
          },
          "position": {
            "x": 400,
            "y": 40
          }
        },
        "flowElementId": "05921F9D-9C10-4431-AB90-1768090D0FD4",
        "groupId": "930D5A2C-C1C6-4551-BC5E-6E99981E8901",
        "id": "0D09BC83-896D-4577-9EBE-8C2D8A3F4AE6",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "all",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Rates",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Rates",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Rates",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "rates",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Carrier rates",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "B7426C5B-3AEB-4AA6-BB4A-168998EDD6A7"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "carrier",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": null,
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "930D5A2C-C1C6-4551-BC5E-6E99981E8901"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const kept = Array.isArray(all) ? all : [];\nconst found = Array.isArray(rates) ? rates : [];\nreturn kept.concat(found.map(r => ({\n  carrierCode: carrier,\n  serviceCode: r.serviceCode,\n  serviceName: r.serviceName,\n  cost: (Number(r.shipmentCost) || 0) + (Number(r.otherCost) || 0),\n})));"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Kept rates",
          "retryPolicy": null,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Rates"
          },
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Keep the carrier's rates",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Flag the order for ops Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 110,
            "y": 390
          }
        },
        "flowElementId": "737A180A-5CC0-4C44-9B1E-06CAC63C0185",
        "groupId": null,
        "id": "39400516-1B36-44FA-B7D6-6525064CA79A",
        "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": "*Order "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "orderNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " needs a label by hand.* No carrier returned a rate, so no label was bought. Check the order's weight and ship-to address in ShipStation."
                  }
                ],
                "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": "No rate message",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Flag the order for ops",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 1468,
            "y": 569
          }
        },
        "flowElementId": "107921AB-140C-41D5-A010-95D199E23798",
        "groupId": null,
        "id": "E5F3D5D8-4822-4DDC-A765-65389D3C2F3C",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Ops decision",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Wait for ops' answer",
        "nextElementIds": [
          "C9015C63-8E14-4A27-A0C4-9002247472FE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves the full details of a single order by its ShipStation order ID, including line items, addresses, totals, weights, dimensions, and advanced options.",
          "elementId": "EXTENSION:::SHARED:::default:::shipstation:::getOrder",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the order Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::shipstation:::getOrder",
          "legacyElementId": "JS###v1###ShipStation###getOrder",
          "methodName": "getOrder",
          "position": {
            "x": 763,
            "y": 220
          }
        },
        "flowElementId": "1998FA0D-95C2-4EA4-9307-504318BBE44D",
        "groupId": null,
        "id": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "orderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New order",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "BB268301-105A-46D7-837B-0076AF30ED5D"
                  }
                ],
                "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": "getOrder",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Order",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "shipstation",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read the order",
        "nextElementIds": [
          "FB3335A0-DF5F-403E-B092-7C36198FE289"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Rates": "c3407424-2163-4378-9849-78b31f9e05cd"
          },
          "position": {
            "x": 1460,
            "y": 399
          }
        },
        "flowElementId": "F093D5BF-1C59-4B96-BB17-FEC67332F306",
        "groupId": null,
        "id": "A3AF51CA-AD0A-4526-96AD-E2C97721C82E",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Rates",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_LIST",
                    "label": null,
                    "type": "KEYWORD",
                    "value": "arrays.create()"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "bucket",
          "storeResult": true
        },
        "name": "Start an empty rate list",
        "nextElementIds": [],
        "nextGroupIds": [
          "930D5A2C-C1C6-4551-BC5E-6E99981E8901"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Skip a carrier with no rates Result"
          },
          "position": {
            "x": 400,
            "y": 220
          }
        },
        "flowElementId": "6BFFEF0F-7515-4EBA-BA28-9A481EE63543",
        "groupId": "930D5A2C-C1C6-4551-BC5E-6E99981E8901",
        "id": "7038CDEF-3EA4-4290-817B-8C0242F11EEE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Carrier error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Skip a carrier with no rates",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1469,
            "y": 739
          }
        },
        "flowElementId": "6000FC14-0D9E-430B-9D8C-FDD76E1E3FE5",
        "groupId": null,
        "id": "C9015C63-8E14-4A27-A0C4-9002247472FE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "5b0573f7-db0e-4d40-9778-95989c900e87",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Ops decision",
                      "subPathSegments": [
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "E5F3D5D8-4822-4DDC-A765-65389D3C2F3C"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "buy"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "5b0573f7-db0e-4d40-9778-95989c900e87"
            ]
          },
          "elseComponent": {
            "componentId": "8E5F9210-B9DD-40CA-BE7C-9D9BAE87AABA",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cbuy",
          "storeResult": false,
          "thenComponent": {
            "componentId": "55728100-0A3A-4B72-901C-4B82628B2612",
            "componentType": "ELEMENT"
          }
        },
        "name": "Buy it?",
        "nextElementIds": [
          "8E5F9210-B9DD-40CA-BE7C-9D9BAE87AABA",
          "55728100-0A3A-4B72-901C-4B82628B2612"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a shipping label for an order that already exists in ShipStation and returns the label data, tracking number, and cost. The order supplies the addresses, so only the carrier, service, confirmation, and ship date are required. The returned labelData is a base64-encoded PDF. Charges the connected carrier account unless Test Label is on.",
          "elementId": "EXTENSION:::SHARED:::default:::shipstation:::createLabelForOrder",
          "isFirstElement": false,
          "dynamicOptionLabels": {
            "confirmation": {
              "none": "None"
            }
          },
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Buy the label Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::shipstation:::createLabelForOrder",
          "legacyElementId": "JS###v1###ShipStation###createLabelForOrder",
          "methodName": "createLabelForOrder",
          "position": {
            "x": 1115,
            "y": 730
          }
        },
        "flowElementId": "C6DF7EF7-398A-4731-9098-7DDD6D16DABC",
        "groupId": null,
        "id": "55728100-0A3A-4B72-901C-4B82628B2612",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "orderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "carrierCode",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "carrierCode",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "serviceCode",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "serviceCode",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "confirmation",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "none"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "shipDate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "shipDate",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "packageCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "testLabel",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "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": "createLabelForOrder",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Label",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "shipstation",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Buy the label",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Pick the cheapest rate Result"
          },
          "position": {
            "x": 756,
            "y": 399
          }
        },
        "flowElementId": "CB22D7C7-DFEF-4A97-A98D-7B324BFCDB79",
        "groupId": null,
        "id": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "rates",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Rates",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Rates",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Rates",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderTotal",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "orderTotal",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maxCost",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Most a label may cost",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Most a label may cost"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maxShare",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Most share of order value",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Most share of order value"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = (Array.isArray(rates) ? rates : []).filter(r => r.serviceCode && r.cost > 0);\nlist.sort((a, b) => a.cost - b.cost);\nconst best = list[0];\nconst total = Number(orderTotal) || 0;\nconst shipDate = new Date().toISOString().slice(0, 10);\nif (!best) {\n  return { found: false, withinLimits: false, shipDate, options: '' };\n}\nconst share = total > 0 ? Math.round((best.cost / total) * 100) : null;\nconst withinLimits = best.cost <= Number(maxCost) && (share === null || share <= Number(maxShare));\nconst options = list.slice(0, 3).map(r => `${r.serviceName}: $${r.cost.toFixed(2)}`).join('\\n');\nreturn {\n  found: true,\n  carrierCode: best.carrierCode,\n  serviceCode: best.serviceCode,\n  serviceName: best.serviceName,\n  cost: best.cost.toFixed(2),\n  share,\n  withinLimits,\n  shipDate,\n  options,\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Best rate",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Pick the cheapest rate",
        "nextElementIds": [
          "97C8BEE7-67A0-4C8E-8D52-30DE7AA43313"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 431,
            "y": 399
          }
        },
        "flowElementId": "75A74B26-97C5-4206-B3CA-6F7729EBE10E",
        "groupId": null,
        "id": "97C8BEE7-67A0-4C8E-8D52-30DE7AA43313",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "e1655814-3b7d-45b6-bad4-9ed5d8771fd0",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Best rate",
                      "subPathSegments": [
                        {
                          "key": "found",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "e1655814-3b7d-45b6-bad4-9ed5d8771fd0"
            ]
          },
          "elseComponent": {
            "componentId": "39400516-1B36-44FA-B7D6-6525064CA79A",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cfound",
          "storeResult": false,
          "thenComponent": {
            "componentId": "E0BA479B-13C6-4F8F-9E1E-B5E336FECE6F",
            "componentType": "ELEMENT"
          }
        },
        "name": "Any rate found?",
        "nextElementIds": [
          "39400516-1B36-44FA-B7D6-6525064CA79A",
          "E0BA479B-13C6-4F8F-9E1E-B5E336FECE6F"
        ],
        "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": "Ask ops before buying Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1108,
            "y": 560
          }
        },
        "flowElementId": "6E3F5831-5EB1-4618-99E6-1E9398DB4E28",
        "groupId": null,
        "id": "675C2CD8-C1DA-4505-8ACE-CDF78E1589E3",
        "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": "ADAAE778-48E8-489E-9D80-3D3372533F5D"
                  }
                ],
                "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": "ADAAE778-48E8-489E-9D80-3D3372533F5D"
                  }
                ],
                "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 ops",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask ops before buying",
        "nextElementIds": [
          "E5F3D5D8-4822-4DDC-A765-65389D3C2F3C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Confirm the order is held Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1100,
            "y": 860
          }
        },
        "flowElementId": "EBCB95D1-725F-46F7-A0AE-E3F83EC643E5",
        "groupId": null,
        "id": "8E5F9210-B9DD-40CA-BE7C-9D9BAE87AABA",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Held. No label was bought for order "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "orderNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". It stays in ShipStation awaiting shipment for review."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Question to ops",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "675C2CD8-C1DA-4505-8ACE-CDF78E1589E3"
                  }
                ],
                "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": "Held message",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Confirm the order is held",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when a new order is created in ShipStation, optionally limited to a single store or order status. Orders are matched by their ShipStation creation date. Polling interval can be customized (minimum 30 seconds).",
          "elementId": "EXTENSION:::SHARED:::default:::shipstation:::onNewOrder",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::shipstation:::onNewOrder",
          "newElementId": "EXTENSION:::SHARED:::default:::shipstation:::onNewOrder",
          "legacyElementId": "JS###v1###ShipStation###onNewOrder",
          "methodName": "onNewOrder",
          "position": {
            "x": 424,
            "y": 220
          }
        },
        "flowElementId": "3D6C510E-E2E3-457C-918B-BA57D0F4E236",
        "groupId": null,
        "id": "BB268301-105A-46D7-837B-0076AF30ED5D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onNewOrder",
          "frequency": {
            "repeat": {
              "every": 300
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New order",
          "serviceId": "shipstation",
          "slaConditions": [],
          "staticData": {
            "orderStatus": "awaiting_shipment"
          },
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "New ShipStation order",
        "nextElementIds": [
          "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 419,
            "y": 569
          }
        },
        "flowElementId": "7D99DDE8-61CF-4486-981C-6D7E540739F6",
        "groupId": null,
        "id": "E0BA479B-13C6-4F8F-9E1E-B5E336FECE6F",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "dbf3112c-1a1b-4b35-8e0b-c44aa8e10d3e",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Best rate",
                      "subPathSegments": [
                        {
                          "key": "withinLimits",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "dbf3112c-1a1b-4b35-8e0b-c44aa8e10d3e"
            ]
          },
          "elseComponent": {
            "componentId": "ADAAE778-48E8-489E-9D80-3D3372533F5D",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "climit",
          "storeResult": false,
          "thenComponent": {
            "componentId": "55728100-0A3A-4B72-901C-4B82628B2612",
            "componentType": "ELEMENT"
          }
        },
        "name": "Label cost within limits?",
        "nextElementIds": [
          "ADAAE778-48E8-489E-9D80-3D3372533F5D",
          "55728100-0A3A-4B72-901C-4B82628B2612"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the question for ops Result"
          },
          "position": {
            "x": 743,
            "y": 569
          }
        },
        "flowElementId": "108B6E4D-FAEC-4B9E-9B82-DFC23C22BDC5",
        "groupId": null,
        "id": "ADAAE778-48E8-489E-9D80-3D3372533F5D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "orderNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "orderNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderTotal",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "orderTotal",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "shipTo",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "shipTo",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cost",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "cost",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "share",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "share",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "serviceName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "serviceName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "options",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Best rate",
                    "subPathSegments": [
                      {
                        "key": "options",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
                  }
                ],
                "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 to = shipTo || {};\nconst place = [to.name, [to.city, to.state].filter(Boolean).join(' ')].filter(Boolean).join(', ');\nconst lines = [\n  `*Order ${orderNumber}: the cheapest label is $${cost} on a $${(Number(orderTotal) || 0).toFixed(2)} order*`,\n  share !== null && share !== undefined ? `That is ${share}% of the order value.` : null,\n  `Cheapest service: ${serviceName}`,\n  `Cheapest rates:\\n${options}`,\n  place ? `Ship to: ${place}` : null,\n].filter(Boolean);\nreturn {\n  text: `Order ${orderNumber}: the cheapest label is $${cost}. Buy it?`,\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: 'Buy the label' }, url: link('buy') },\n      { type: 'button', text: { type: 'plain_text', text: 'Hold for review' }, url: link('hold') },\n    ] },\n  ],\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Question card",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the question for ops",
        "nextElementIds": [
          "675C2CD8-C1DA-4505-8ACE-CDF78E1589E3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves the list of warehouses (Ship From Locations) configured in the ShipStation account, including their origin and return addresses.",
          "elementId": "EXTENSION:::SHARED:::default:::shipstation:::listWarehouses",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the ship-from warehouse Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::shipstation:::listWarehouses",
          "legacyElementId": "JS###v1###ShipStation###listWarehouses",
          "methodName": "listWarehouses",
          "position": {
            "x": 1082,
            "y": 220
          }
        },
        "flowElementId": "D60E0DBF-FD31-44C8-8EDA-BE5965619181",
        "groupId": null,
        "id": "FB3335A0-DF5F-403E-B092-7C36198FE289",
        "metaInfo": {
          "bodyParams": [],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listWarehouses",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Warehouses",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "shipstation",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the ship-from warehouse",
        "nextElementIds": [
          "1713FEF7-6019-4079-ACDD-E03A55F08942"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the order ready to rate Result"
          },
          "position": {
            "x": 1447,
            "y": 229
          }
        },
        "flowElementId": "88A6C67B-4D90-4B2F-9248-6891728242B1",
        "groupId": null,
        "id": "1713FEF7-6019-4079-ACDD-E03A55F08942",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "order",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "0CE2F8F8-1D1D-472A-91D4-D8B69CBCF0BA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "warehouses",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Warehouses",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "FB3335A0-DF5F-403E-B092-7C36198FE289"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = Array.isArray(warehouses) ? warehouses : [];\nconst wanted = order.advancedOptions ? order.advancedOptions.warehouseId : null;\nconst warehouse = list.find(w => wanted && String(w.warehouseId) === String(wanted))\n  || list.find(w => w.isDefault) || list[0] || {};\nconst from = warehouse.originAddress || {};\nconst to = order.shipTo || {};\nconst weight = order.weight || {};\nreturn {\n  fromPostalCode: from.postalCode || '',\n  fromCity: from.city || '',\n  fromState: from.state || '',\n  toPostalCode: to.postalCode || '',\n  toCountry: to.country || '',\n  toState: to.state || '',\n  toCity: to.city || '',\n  residential: to.residential === true,\n  weightValue: Number(weight.value) || 0,\n  weightUnits: weight.units || 'ounces',\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Rate request",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Get the order ready to rate",
        "nextElementIds": [
          "A3AF51CA-AD0A-4526-96AD-E2C97721C82E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "BB268301-105A-46D7-837B-0076AF30ED5D",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": 0,
            "y": 0,
            "zoom": 0.8
          },
          "position": {
            "x": 1092,
            "y": 399
          }
        },
        "flowElementId": "03FC0843-6422-4C87-BC75-D22B2E7CF8E1",
        "groupId": null,
        "id": "930D5A2C-C1C6-4551-BC5E-6E99981E8901",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "enabled": true,
          "firstElementId": "B7426C5B-3AEB-4AA6-BB4A-168998EDD6A7",
          "list": {
            "expression": [
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Carriers",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Carriers"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "loop",
          "storeResult": true
        },
        "name": "Get rates from each carrier",
        "nextElementIds": [
          "E84A0EAD-BB67-41FC-8FCA-42CA40ABBDF0"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "AA0FE2D3-52E6-4004-B58D-65589648697B",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [
        {
          "description": "ShipStation carrier codes to compare rates across.",
          "error": null,
          "name": "Carriers",
          "type": "ARRAY",
          "value": ""
        },
        {
          "description": "Dollars. A label above this price goes to ops in Slack before it is bought.",
          "error": null,
          "name": "Most a label may cost",
          "type": "INT",
          "value": ""
        },
        {
          "description": "Percent of the order total a label may cost before ops is asked.",
          "error": null,
          "name": "Most share of order value",
          "type": "INT",
          "value": ""
        },
        {
          "description": "URL of the block Wait for ops' 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-11-19T02:35:38.479Z"
}
