{
"Comment": "High-throughput express spam and phishing detection for inbound messages. Classifies content, waits for policy threshold check, then routes to auto-block or allow with feedback loop.",
"StartAt": "SetSpamDetectionContext",
"States": {
"SetSpamDetectionContext": {
"Type": "Pass",
"Parameters": {
"contentId.$": "$.contentId",
"contentType.$": "$.contentType",
"platform.$": "$.platform",
"source.$": "$.source",
"submittedBy.$": "$.submittedBy",
"metadata.$": "$.metadata",
"rawContent.$": "$.rawContent",
"spamDetectionMode": "EXPRESS",
"policies": [
"SPAM",
"PHISHING",
"SCAM"
],
"autoBlockThreshold": 0.65
},
"Next": "ExpressIngestMessage"
},
"ExpressIngestMessage": {
"Type": "Task",
"Resource": "${IngestContentFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "SpamDetectionFailed"
}
],
"Next": "ExpressClassifyForSpam"
},
"ExpressClassifyForSpam": {
"Type": "Task",
"Resource": "${ClassifyContentFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "SpamDetectionFailed"
}
],
"Next": "WaitForThresholdPolicy"
},
"WaitForThresholdPolicy": {
"Type": "Wait",
"Seconds": 2,
"Next": "RouteBySpamScore"
},
"RouteBySpamScore": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.classification.overallDecision",
"StringEquals": "AUTO_APPROVE",
"Next": "UpdateSpamFeedback"
}
],
"Default": "ExpressBlockContent"
},
"ExpressBlockContent": {
"Type": "Task",
"Resource": "${ApplyModerationActionFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "SpamDetectionFailed"
}
],
"Next": "UpdateSpamFeedback"
},
"UpdateSpamFeedback": {
"Type": "Task",
"Resource": "${UpdateClassifierFeedbackFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "SpamDetectionFailed"
}
],
"Next": "NotifySpamOutcome"
},
"NotifySpamOutcome": {
"Type": "Task",
"Resource": "${NotifyModerationOutcomeFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Next": "SpamDetectionComplete"
},
"SpamDetectionComplete": {
"Type": "Succeed"
},
"SpamDetectionFailed": {
"Type": "Fail",
"Error": "SpamDetectionFailed",
"Cause": "Express spam detection failed. Message status is unresolved."
}
}
}JSONExpand
100%
AI 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.