{
"Comment": "Document analysis pipeline: ingest and extract text via Lambda, summarize and classify via Amazon Bedrock, then store and notify.",
"StartAt": "IngestDocument",
"States": {
"IngestDocument": {
"Type": "Task",
"Resource": "${IngestDocumentFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "AnalysisFailed"
}
],
"Next": "ExtractText"
},
"ExtractText": {
"Type": "Task",
"Resource": "${ExtractTextFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "AnalysisFailed"
}
],
"Next": "SummarizeDocument"
},
"SummarizeDocument": {
"Type": "Task",
"Resource": "arn:aws:states:::bedrock:invokeModel",
"Parameters": {
"ModelId": "us.amazon.nova-lite-v1:0",
"Body": {
"messages": [
{
"role": "user",
"content": [
{
"text.$": "States.Format('Summarize the following document in 3-5 sentences. Return a JSON object with keys: summary (string), keyPoints (array of strings), wordCount (number).\n\nDocument:\n{}', $.textExtraction.extractedText)"
}
]
}
],
"inferenceConfig": {
"maxTokens": 1024
}
}
},
"ResultSelector": {
"rawResponse.$": "$.Body.output.message.content[0].text"
},
"ResultPath": "$.bedrockSummary",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 3,
"MaxAttempts": 2,
"BackoffRate": 1.5
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "AnalysisFailed"
}
],
"Next": "ClassifyDocument"
},
"ClassifyDocument": {
"Type": "Task",
"Resource": "arn:aws:states:::bedrock:invokeModel",
"Parameters": {
"ModelId": "us.amazon.nova-lite-v1:0",
"Body": {
"messages": [
{
"role": "user",
"content": [
{
"text.$": "States.Format('Classify the following document. Return a JSON object with keys: primaryCategory (string), secondaryCategories (array of strings), confidenceScore (number 0-1), language (string), sentiment (POSITIVE|NEUTRAL|NEGATIVE).\n\nDocument:\n{}', $.textExtraction.extractedText)"
}
]
}
],
"inferenceConfig": {
"maxTokens": 512
}
}
},
"ResultSelector": {
"rawResponse.$": "$.Body.output.message.content[0].text"
},
"ResultPath": "$.bedrockClassification",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 3,
"MaxAttempts": 2,
"BackoffRate": 1.5
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "AnalysisFailed"
}
],
"Next": "StoreAnalysis"
},
"StoreAnalysis": {
"Type": "Task",
"Resource": "${StoreAnalysisFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "AnalysisFailed"
}
],
"Next": "NotifyAnalysisComplete"
},
"NotifyAnalysisComplete": {
"Type": "Task",
"Resource": "${NotifyAnalysisCompleteFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 1,
"BackoffRate": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "AnalysisFailed"
}
],
"Next": "AnalysisComplete"
},
"AnalysisComplete": {
"Type": "Succeed"
},
"AnalysisFailed": {
"Type": "Fail",
"Error": "AnalysisFailed",
"Cause": "Document analysis pipeline encountered an unrecoverable error."
}
}
}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.