AWS Step Functions to Amazon SageMaker AI confidence gate

Ticket → Amazon SageMaker AI → Choice state → Amazon SNS → Amazon SQS

An AWS Step Functions Choice state acts on the answers of an open-weight Strands Decider model on Amazon SageMaker AI only when it is confident; the rest go to Amazon SQS.

This pattern deploys an AWS Step Functions Express workflow that calls an Amazon SageMaker AI endpoint serving the open-weight Strands Decider decision model, directly through the AWS SDK integration. The model answers three typed questions about a support ticket in one call: a choice for the owning department, a score for urgency, and a yes/no question about an active security incident.
A Choice state is the confidence gate. A confident department answer is auto-routed. A suspected security incident is published to an Amazon SNS topic and still goes to a person. Everything else, including any ticket for which the model call failed or returned something unusable, goes to an Amazon SQS human-review queue with a dead-letter queue behind it.
The stack builds the model container image, so you need a container builder (Docker, or Finch with CDK_DOCKER=finch), and the account and Region must be bootstrapped with npx cdk bootstrap.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/sfn-sagemaker-sqs-sns/typescript/cdk

Deploy

npm installnpx cdk deploy


Testing

Run the three sample tickets in the events folder: a clear one is auto-routed, an ambiguous one goes to the Amazon SQS review queue, and a security one also sends a page to Amazon SNS.
See the GitHub repo for the commands and expected output.

Cleanup

Delete the stack: npx cdk destroy.
Delete the endpoint log group that Amazon SageMaker AI creates: aws logs delete-log-group --log-group-name /aws/sagemaker/Endpoints/$ENDPOINT. Read $ENDPOINT from the DeciderEndpointName stack output before you delete the stack.

Created by:

Nithin Chandran R

Nithin Chandran R

Technical Account Manager at AWS