Express Rate Check

This workflow provides a low-latency express rate quote before a full freight booking is submitted. It checks carrier capacity, calculates indicative rates, and applies a brief Wait for rate propagation before returning a Succeed or Fail terminal state.

{
  "Comment": "Express rate check: quickly verify carrier capacity and calculate freight rates before committing to a full booking",
  "StartAt": "SetCheckMeta",
  "States": {
    "SetCheckMeta": {
      "Type": "Pass",
      "Parameters": {
        "checkId.$": "States.Format('RCK-{}', $$.Execution.Name)",
        "channel": "EXPRESS",
        "booking.$": "$"
      },
      "Next": "CheckCarrierCapacity"
    },
    "CheckCarrierCapacity": {
      "Type": "Task",
      "Resource": "${CheckCarrierCapacityFunctionArn}",
      "ResultPath": "$.capacity",
      "Next": "IsCapacityAvailable"
    },
    "IsCapacityAvailable": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.capacity.Payload.isCapacityAvailable",
          "BooleanEquals": true,
          "Next": "CalculateFreightRates"
        }
      ],
      "Default": "RateUnavailable"
    },
    "CalculateFreightRates": {
      "Type": "Task",
      "Resource": "${CalculateFreightRatesFunctionArn}",
      "ResultPath": "$.rates",
      "Next": "RatePropagationDelay"
    },
    "RatePropagationDelay": {
      "Type": "Wait",
      "Seconds": 2,
      "Next": "IsRateCalculated"
    },
    "IsRateCalculated": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.rates.Payload.totalRate",
          "NumericGreaterThan": 0,
          "Next": "RateAvailable"
        }
      ],
      "Default": "RateUnavailable"
    },
    "RateAvailable": {
      "Type": "Succeed"
    },
    "RateUnavailable": {
      "Type": "Fail",
      "Error": "RateUnavailable",
      "Cause": "No rate could be determined for this shipment"
    }
  }
}
JSON
Expand
100%

Logistics teams can use patterns like this to build reliable, compliant, and scalable automation for payment systems and can test and refine these flows locally with Thrubit to reduce cloud cost and speed up iteration.