{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "0C9D229F-DF47-4FD8-AE66-7DE879B77A83",
    "name": "Sendcloud: Shopify order to label"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -49.297131232116044,
        "y": 47.23445235958724,
        "zoom": 0.5358867312681465
      },
      "autoSave": true,
      "descriptions": {
        "flow": "When a Shopify order comes in, checks the shipping address and weight, picks the cheapest Sendcloud shipping method for the destination and weight, buys the label, and registers the tracking number with AfterShip. Orders that cannot be labeled go to the warehouse in Slack.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a Shopify order comes in, checks the shipping address and weight, picks the cheapest Sendcloud shipping method for the destination and weight, buys the label, and registers the tracking number with AfterShip. Orders that cannot be labeled go to the warehouse in Slack.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Retrieves the shipping methods available to your account, optionally filtered by the sender address and destination country. Each method includes its ID, name, carrier, price, and supported weight range. Use a method's ID as the Shipping Method ID when creating a parcel.",
          "elementId": "EXTENSION:::SHARED:::default:::sendcloud:::listShippingMethods",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List shipping methods Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sendcloud:::listShippingMethods",
          "legacyElementId": "JS###v1###SendcloudService###listShippingMethods",
          "methodName": "listShippingMethods",
          "position": {
            "x": 818,
            "y": 438
          }
        },
        "flowElementId": "A4C0228F-5AA5-4981-AD91-6187AA3231E2",
        "groupId": null,
        "id": "56F386B9-BDAB-4973-BBAE-B4052CDA188A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "senderAddressId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toCountry",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "country",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "servicePoints",
              "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": "listShippingMethods",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Methods",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sendcloud",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List shipping methods",
        "nextElementIds": [
          "ABB6904B-5FF2-42F1-9AF2-D6E71375934D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a single order by its ID with full details: line items with their weight and tax lines, customer, addresses, total weight and custom attributes.",
          "elementId": "EXTENSION:::SHARED:::default:::shopify:::getOrder",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the order Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::shopify:::getOrder",
          "legacyElementId": "JS###v1###Shopify###getOrder",
          "methodName": "getOrder",
          "position": {
            "x": 400,
            "y": 270
          }
        },
        "flowElementId": "F57F27A8-E2F4-464A-B59C-559C5F3C9A9D",
        "groupId": null,
        "id": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "orderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New order",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "B3F865B2-70CF-4E82-B6CF-5DEE0EEF6C61"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Get the order', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getOrder",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Order",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "shopify",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the order",
        "nextElementIds": [
          "3728C74B-69AA-46BA-9377-9582730767B4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new parcel (shipment) in Sendcloud for a recipient address. Set Request Label to true to immediately buy a label with the selected shipping method, or leave it false to create the parcel as a draft/announcement. The shipping method is chosen via its ID (use List Shipping Methods). Returns the created parcel including its ID, status, tracking number, and label URLs when a label was requested.",
          "elementId": "EXTENSION:::SHARED:::default:::sendcloud:::createParcel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Buy the label in Sendcloud Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sendcloud:::createParcel",
          "legacyElementId": "JS###v1###SendcloudService###createParcel",
          "methodName": "createParcel",
          "position": {
            "x": 1287.2078457353578,
            "y": 745.801774414293
          }
        },
        "flowElementId": "AAED52D9-1AB7-4169-9142-55233BF665C8",
        "groupId": null,
        "id": "CC205ED2-7C5F-4C6C-8CBB-2A24909273F5",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "name",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "address",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "street",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "houseNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "houseNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "city",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "city",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "postalCode",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "postalCode",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "country",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "country",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "telephone",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "phone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "company",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "weight",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "weightKg",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "shippingMethodId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Method",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ABB6904B-5FF2-42F1-9AF2-D6E71375934D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "requestLabel",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "address2",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "address2",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "countryState",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "countryState",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "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": "createParcel",
          "onFailElemId": "74235CC2-77BC-400D-A7E4-088DADB8E723",
          "packageId": "default",
          "resultAlias": "Parcel",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sendcloud",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Buy the label in Sendcloud",
        "nextElementIds": [
          "F0DAE3D3-1DE2-4745-A15F-A72051205F6C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1028,
            "y": 270
          }
        },
        "flowElementId": "6F61DEF6-B79C-4FA4-A27D-CAE9DE365376",
        "groupId": null,
        "id": "A84168F9-D61D-474A-9BE4-B79A00C8A031",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "cab72dbb-ecce-45cb-a519-7209991190dd",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Check",
                      "subPathSegments": [
                        {
                          "key": "ok",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "cab72dbb-ecce-45cb-a519-7209991190dd"
            ]
          },
          "elseComponent": {
            "componentId": "F65A4AFC-F869-44B2-AB85-9BBBF3C42593",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Address complete",
          "storeResult": false,
          "thenComponent": {
            "componentId": "56F386B9-BDAB-4973-BBAE-B4052CDA188A",
            "componentType": "ELEMENT"
          }
        },
        "name": "Address complete?",
        "nextElementIds": [
          "56F386B9-BDAB-4973-BBAE-B4052CDA188A",
          "F65A4AFC-F869-44B2-AB85-9BBBF3C42593"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Pick the cheapest method Result"
          },
          "position": {
            "x": 800.8036041015583,
            "y": 609.8660659830736
          }
        },
        "flowElementId": "02A98F0A-5F47-4F00-90A5-DB29F1F5F763",
        "groupId": null,
        "id": "ABB6904B-5FF2-42F1-9AF2-D6E71375934D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "methods",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Methods",
                    "subPathSegments": [
                      {
                        "key": "shipping_methods",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "56F386B9-BDAB-4973-BBAE-B4052CDA188A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "weight",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "weight",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "country",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "country",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Keeps the methods that serve the destination country and take this weight,\n// then picks the cheapest. Method 8 (Unstamped letter) buys no label, so it is skipped.\nconst list = Array.isArray(methods) ? methods : [];\nconst w = Number(weight);\nconst fits = list\n  .filter(m => m.id !== 8)\n  .filter(m => w >= Number(m.min_weight || 0) && w <= Number(m.max_weight || Infinity))\n  .map(m => {\n    const c = (m.countries || []).find(c => String(c.iso_2 || '').toUpperCase() === country);\n    return c ? { m, price: Number(c.price != null ? c.price : (m.price || 0)) } : null;\n  })\n  .filter(Boolean)\n  .sort((a, b) => a.price - b.price);\n\nconst best = fits[0];\nif (!best) {\n  return {\n    found: false,\n    reason: 'No Sendcloud shipping method takes a ' + w.toFixed(3) + ' kg parcel to ' + country + '.',\n    methodsChecked: list.length,\n  };\n}\nreturn {\n  found: true,\n  reason: '',\n  id: best.m.id,\n  name: best.m.name,\n  carrier: best.m.carrier,\n  price: best.price,\n  methodsChecked: list.length,\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Method",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Pick the cheapest method",
        "nextElementIds": [
          "87C5053B-C40C-42B1-9F6B-92DAAA8905E2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check the address and weight Result"
          },
          "position": {
            "x": 690,
            "y": 270
          }
        },
        "flowElementId": "16C00926-1CA1-4674-8BDA-FA929B8C2F8E",
        "groupId": null,
        "id": "3728C74B-69AA-46BA-9377-9582730767B4",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "address",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "shippingAddress",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customerEmail",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "customer",
                        "optional": false
                      },
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderPhone",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "phone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "totalWeight",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "totalWeight",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lineItems",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "lineItems",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Checks that the order can be labeled without a person: a complete shipping address,\n// an email for tracking updates, and a weight. Splits the street from the house number\n// for Sendcloud and converts Shopify grams to kilograms.\nconst clean = v => (v == null ? '' : String(v).trim());\nconst a = address || null;\nconst problems = [];\n\nconst name = a ? [clean(a.firstName), clean(a.lastName)].filter(Boolean).join(' ') : '';\nconst line1 = a ? clean(a.address1) : '';\nlet line2 = a ? clean(a.address2) : '';\nconst city = a ? clean(a.city) : '';\nconst postalCode = a ? clean(a.zip) : '';\nconst country = a ? clean(a.countryCode).toUpperCase() : '';\nconst mail = clean(email) || clean(customerEmail);\n\nif (!a) {\n  problems.push('The order has no shipping address.');\n} else {\n  if (!name) problems.push('The recipient name is missing.');\n  if (!line1) problems.push('The street address is missing.');\n  if (!city) problems.push('The city is missing.');\n  if (!postalCode) problems.push('The postal code is missing.');\n  if (!country) problems.push('The country is missing.');\n}\nif (!mail) problems.push('There is no email for tracking updates.');\n\n// House number first (12 Main St) or last (Insulindelaan 115).\nlet street = line1;\nlet houseNumber = '';\nconst num = '\\\\d+[a-zA-Z]?(?:\\\\s?[-/]\\\\s?\\\\d+[a-zA-Z]?)?';\nlet m = line1.match(new RegExp('^(' + num + ')[,\\\\s]+(.+)$'));\nif (m) {\n  houseNumber = m[1];\n  street = m[2];\n} else {\n  m = line1.match(new RegExp('^(.+?)[,\\\\s]+(' + num + '(?:\\\\s?[a-zA-Z])?)$'));\n  if (m) {\n    street = m[1];\n    houseNumber = m[2];\n  } else if (/^\\d+[a-zA-Z]?$/.test(line2)) {\n    houseNumber = line2;\n    line2 = '';\n  }\n}\nif (line1 && !houseNumber) problems.push('There is no house number in the street address.');\n\n// Carriers need the state or province for the United States and Canada.\nconst state = a ? clean(a.provinceCode) : '';\nif ((country === 'US' || country === 'CA') && !state) problems.push('The state or province is missing.');\n\n// Weight: the order total in grams, or the line items when the total is missing.\nconst toGrams = w => {\n  if (!w || w.value == null) return 0;\n  const v = Number(w.value) || 0;\n  switch (String(w.unit || '').toUpperCase()) {\n    case 'KILOGRAMS': return v * 1000;\n    case 'POUNDS': return v * 453.592;\n    case 'OUNCES': return v * 28.3495;\n    default: return v;\n  }\n};\nlet grams = Number(totalWeight) || 0;\nif (!grams && Array.isArray(lineItems)) {\n  grams = lineItems.reduce((sum, i) => sum + toGrams(i.weight) * (Number(i.quantity) || 1), 0);\n}\nif (!grams) problems.push('The products on the order have no weight.');\nconst kg = grams / 1000;\n\nreturn {\n  ok: problems.length === 0,\n  reason: problems.join(' '),\n  name,\n  company: a ? clean(a.company) : '',\n  street,\n  houseNumber,\n  address2: line2,\n  city,\n  postalCode,\n  country,\n  countryState: state,\n  email: mail,\n  phone: (a ? clean(a.phone) : '') || clean(orderPhone),\n  weightKg: kg.toFixed(3),\n  weight: kg,\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Check",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Check the address and weight",
        "nextElementIds": [
          "A84168F9-D61D-474A-9BE4-B79A00C8A031"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new tracking so AfterShip begins monitoring a shipment across 1000+ supported carriers. Only tracking_number is strictly required; providing the courier slug avoids auto-detection. Supports a display title and arbitrary custom fields. AfterShip wraps the payload in a {tracking:{...}} envelope automatically.",
          "elementId": "EXTENSION:::SHARED:::default:::aftership:::createTracking",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Track it in AfterShip Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::aftership:::createTracking",
          "legacyElementId": "JS###v1###AfterShipService###createTracking",
          "methodName": "createTracking",
          "position": {
            "x": 1309.8938936600623,
            "y": 946.9080677737769
          }
        },
        "flowElementId": "597998A3-845D-436B-8B1F-174E3D0140E4",
        "groupId": null,
        "id": "F0DAE3D3-1DE2-4745-A15F-A72051205F6C",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "trackingNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Parcel",
                    "subPathSegments": [
                      {
                        "key": "parcel",
                        "optional": false
                      },
                      {
                        "key": "tracking_number",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "CC205ED2-7C5F-4C6C-8CBB-2A24909273F5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "slug",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "title",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Order "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Order",
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  }
                ],
                "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": "createTracking",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Tracking",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "aftership",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Track it in AfterShip",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Label refused Result"
          },
          "position": {
            "x": 1700.3682006182166,
            "y": 755.5609371421275
          }
        },
        "flowElementId": "9879BC9D-EE54-43A1-B935-CDB6C751FA7D",
        "groupId": null,
        "id": "74235CC2-77BC-400D-A7E4-088DADB8E723",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Label error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Label refused",
        "nextElementIds": [
          "F65A4AFC-F869-44B2-AB85-9BBBF3C42593"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 812.9285278645889,
            "y": 762.1339340169264
          }
        },
        "flowElementId": "9DFC5975-79E4-47DB-BA41-D94426D22A07",
        "groupId": null,
        "id": "87C5053B-C40C-42B1-9F6B-92DAAA8905E2",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "9fe8b395-3378-4244-b5a8-691e59c4c73b",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Method",
                      "subPathSegments": [
                        {
                          "key": "found",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "ABB6904B-5FF2-42F1-9AF2-D6E71375934D"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "9fe8b395-3378-4244-b5a8-691e59c4c73b"
            ]
          },
          "elseComponent": {
            "componentId": "F65A4AFC-F869-44B2-AB85-9BBBF3C42593",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Method found",
          "storeResult": false,
          "thenComponent": {
            "componentId": "CC205ED2-7C5F-4C6C-8CBB-2A24909273F5",
            "componentType": "ELEMENT"
          }
        },
        "name": "Method for this parcel?",
        "nextElementIds": [
          "CC205ED2-7C5F-4C6C-8CBB-2A24909273F5",
          "F65A4AFC-F869-44B2-AB85-9BBBF3C42593"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Triggers when a new order is created in your Shopify store. Polling interval can be customized (minimum 30 seconds). Each cycle inspects the 50 most recent orders, so bursts of more than 50 new orders between polls may be missed.",
          "elementId": "EXTENSION:::SHARED:::default:::shopify:::onNewOrder",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::shopify:::onNewOrder",
          "newElementId": "EXTENSION:::SHARED:::default:::shopify:::onNewOrder",
          "legacyElementId": "JS###v1###Shopify###onNewOrder",
          "methodName": "onNewOrder",
          "position": {
            "x": 110,
            "y": 270
          }
        },
        "flowElementId": "52238943-381B-4AA0-B1DA-FF164B773A89",
        "groupId": null,
        "id": "B3F865B2-70CF-4E82-B6CF-5DEE0EEF6C61",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'New Shopify order', Error: OAuth Connection is required",
            "valid": false
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onNewOrder",
          "frequency": {
            "repeat": {
              "every": 60
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New order",
          "serviceId": "shopify",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "New Shopify order",
        "nextElementIds": [
          "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "dynamicOptionLabels": {
            "channelId": {}
          },
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the warehouse to label it by hand Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1320.124923763031,
            "y": 488.776573339871
          }
        },
        "flowElementId": "15C49D39-758E-4304-AB09-F67B6B8444A6",
        "groupId": null,
        "id": "F65A4AFC-F869-44B2-AB85-9BBBF3C42593",
        "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": "name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0662AB16-99BF-4486-86E1-1EA6CE7D94DD"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " needs a label made by hand in Sendcloud. Reason: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": [
                      {
                        "key": "reason",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3728C74B-69AA-46BA-9377-9582730767B4"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Method",
                    "subPathSegments": [
                      {
                        "key": "reason",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ABB6904B-5FF2-42F1-9AF2-D6E71375934D"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Label error",
                    "subPathSegments": [
                      {
                        "key": "message",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "74235CC2-77BC-400D-A7E4-088DADB8E723"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "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": "Warehouse note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the warehouse to label it by hand",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "B3F865B2-70CF-4E82-B6CF-5DEE0EEF6C61",
    "groups": [],
    "id": "1D150FC6-D1B9-4156-86A5-031D3FB0AAC1",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [],
      "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-17T10:06:22.843Z"
}
