{
"Comment": "Express workflow for rapid sentiment and tone scoring of short text via Amazon Bedrock.",
"StartAt": "AnalyseSentiment",
"States": {
"AnalyseSentiment": {
"Type": "Task",
"Resource": "arn:aws:states:::bedrock:invokeModel",
"Parameters": {
"ModelId": "us.amazon.nova-lite-v1:0",
"Body": {
"messages": [
{
"role": "user",
"content": [
{
"text.$": "States.Format('Analyse the sentiment of this text. Return JSON with: sentiment (POSITIVE|NEUTRAL|NEGATIVE), score (number -1 to 1), tone (array of strings e.g. [\"formal\",\"urgent\"]), confidence (number 0-1).\n\nText: {}', $.text)"
}
]
}
],
"inferenceConfig": {
"maxTokens": 256
}
}
},
"ResultSelector": {
"rawResponse.$": "$.Body.output.message.content[0].text"
},
"ResultPath": "$.sentimentResult",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 1.5
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "SentimentFailed"
}
],
"Next": "RouteByResult"
},
"RouteByResult": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.sentimentResult.rawResponse",
"IsPresent": true,
"Next": "SentimentComplete"
}
],
"Default": "SentimentFailed"
},
"SentimentComplete": {
"Type": "Succeed"
},
"SentimentFailed": {
"Type": "Fail",
"Error": "SentimentAnalysisFailed",
"Cause": "Bedrock sentiment analysis encountered an 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.