Recall Escalation

This workflow handles escalation of a recall case where an initial inspection or parts order has failed. It re-validates the recall, enforces a brief processing Wait, then re-runs owner notification and parts ordering in parallel before re-scheduling inspection or closing the case with an escalation flag.
{
  "Comment": "Recall escalation workflow: handles cases where an initial inspection or parts order failed. Re-validates the recall, applies a processing hold, re-runs owner notification and parts ordering in parallel, then re-schedules inspection or closes the case with an escalation flag.",
  "StartAt": "SetEscalationMeta",
  "States": {
    "SetEscalationMeta": {
      "Type": "Pass",
      "Parameters": {
        "escalationId.$": "$$.Execution.Name",
        "escalationStatus": "PENDING",
        "escalated": true,
        "originalRecall.$": "$"
      },
      "Next": "ReValidateRecall"
    },
    "ReValidateRecall": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "${ValidateRecallFunctionArn}",
        "Payload.$": "$.originalRecall"
      },
      "ResultPath": "$.validation",
      "Retry": [
        {
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 3,
          "BackoffRate": 2
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "ResultPath": "$.error",
          "Next": "CloseEscalatedCase"
        }
      ],
      "Next": "IsEscalationValid"
    },
    "IsEscalationValid": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.validation.Payload.isValid",
          "BooleanEquals": true,
          "Next": "EscalationProcessingHold"
        }
      ],
      "Default": "CloseEscalatedCase"
    },
    "EscalationProcessingHold": {
      "Type": "Wait",
      "Comment": "Brief hold to allow downstream inventory and notification systems to reset before retry.",
      "Seconds": 5,
      "Next": "ReNotifyAndReOrderParts"
    },
    "ReNotifyAndReOrderParts": {
      "Type": "Parallel",
      "Comment": "Re-dispatch owner notifications and re-order parts concurrently for the escalated recall.",
      "Branches": [
        {
          "StartAt": "ReNotifyOwner",
          "States": {
            "ReNotifyOwner": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "Parameters": {
                "FunctionName": "${NotifyOwnerFunctionArn}",
                "Payload.$": "$.validation.Payload"
              },
              "End": true
            }
          }
        },
        {
          "StartAt": "ReOrderParts",
          "States": {
            "ReOrderParts": {
              "Type": "Task",
              "Resource": "arn:aws:states:::lambda:invoke",
              "Parameters": {
                "FunctionName": "${OrderReplacementPartsFunctionArn}",
                "Payload.$": "$.validation.Payload"
              },
              "End": true
            }
          }
        }
      ],
      "ResultPath": "$.remediation",
      "Next": "IsEscalationResolved"
    },
    "IsEscalationResolved": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.remediation[1].Payload.status",
          "StringEquals": "PARTS_ORDERED",
          "Next": "ReScheduleInspection"
        }
      ],
      "Default": "CloseEscalatedCase"
    },
    "ReScheduleInspection": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "${ScheduleInspectionFunctionArn}",
        "Payload.$": "$.validation.Payload"
      },
      "ResultPath": "$.inspection",
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "ResultPath": "$.error",
          "Next": "CloseEscalatedCase"
        }
      ],
      "Next": "EscalationResolved"
    },
    "CloseEscalatedCase": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "${CloseRecallCaseFunctionArn}",
        "Payload": {
          "closeReason": "ESCALATION_CLOSED",
          "escalated": true,
          "recall.$": "$.originalRecall"
        }
      },
      "ResultPath": "$.closure",
      "Next": "EscalationFailed"
    },
    "EscalationResolved": {
      "Type": "Succeed"
    },
    "EscalationFailed": {
      "Type": "Succeed"
    }
  }
}
JSON
Expand
100%

Automotive 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.

Free Trial