Player Onboarding Pipeline

This workflow handles the complete new player onboarding journey. It validates the incoming account registration, assigns a personalised tutorial track based on platform and experience level, generates a dynamic AI welcome message using Amazon Bedrock, then waits for tutorial completion before awarding the starter item pack and marking the player as fully onboarded.

{
  "Comment": "Player onboarding pipeline — validates account, assigns tutorial track, generates a personalized welcome via Bedrock, and awards starter pack.",
  "StartAt": "ValidateAccount",
  "States": {
    "ValidateAccount": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "${ValidateAccountFunctionArn}",
        "Payload.$": "$"
      },
      "ResultSelector": {
        "isValid.$": "$.Payload.isValid",
        "isBanned.$": "$.Payload.isBanned",
        "playerId.$": "$.Payload.playerId",
        "username.$": "$.Payload.username",
        "email.$": "$.Payload.email",
        "platform.$": "$.Payload.platform",
        "experienceLevel.$": "$.Payload.experienceLevel",
        "preferredGenre.$": "$.Payload.preferredGenre",
        "region.$": "$.Payload.region",
        "message.$": "$.Payload.message"
      },
      "ResultPath": "$.accountValidation",
      "Retry": [
        {
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 3,
          "BackoffRate": 2.0
        }
      ],
      "Catch": [
        {
          "ErrorEquals": ["States.ALL"],
          "ResultPath": "$.error",
          "Next": "ValidationFailed"
        }
      ],
      "Next": "IsAccountValid"
    },
    "IsAccountValid": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.accountValidation.isBanned",
          "BooleanEquals": true,
          "Next": "AccountBanned"
        },
        {
          "Variable": "$.accountValidation.isValid",
          "BooleanEquals": false,
          "Next": "ValidationFailed"
        }
      ],
      "Default": "AssignTutorial"
    },
    "AccountBanned": {
      "Type": "Fail",
      "Error": "AccountBanned",
      "Cause": "Player account is banned and cannot be onboarded"
    },
    "ValidationFailed": {
      "Type": "Fail",
      "Error": "ValidationFailed",
      "Cause": "Account validation failed due to missing or invalid fields"
    },
    "AssignTutorial": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "${AssignTutorialFunctionArn}",
        "Payload": {
          "playerId.$": "$.accountValidation.playerId",
          "platform.$": "$.accountValidation.platform",
          "experienceLevel.$": "$.accountValidation.experienceLevel"
        }
      },
      "ResultSelector": {
        "tutorialTrackId.$": "$.Payload.tutorialTrackId",
        "tutorialTrackName.$": "$.Payload.tutorialTrackName",
        "estimatedMinutes.$": "$.Payload.estimatedMinutes",
        "modules.$": "$.Payload.modules"
      },
      "ResultPath": "$.tutorialAssignment",
      "Retry": [
        {
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 3,
          "BackoffRate": 2.0
        }
      ],
      "Catch": [
        {
          "ErrorEquals": ["States.ALL"],
          "ResultPath": "$.error",
          "Next": "TutorialAssignmentFailed"
        }
      ],
      "Next": "GenerateWelcomeMessage"
    },
    "TutorialAssignmentFailed": {
      "Type": "Fail",
      "Error": "TutorialAssignmentFailed",
      "Cause": "Failed to assign tutorial track to new player"
    },
    "GenerateWelcomeMessage": {
      "Type": "Task",
      "Resource": "arn:aws:states:::bedrock:invokeModel",
      "Parameters": {
        "ModelId": "anthropic.claude-3-5-sonnet-20241022-v2:0",
        "Body": {
          "anthropic_version": "bedrock-2023-05-31",
          "max_tokens": 180,
          "messages": [
            {
              "role": "user",
              "content.$": "States.Format('Write a short, exciting welcome message (2-3 sentences) for a new game player named {} joining on platform {}. They enjoy {} games and are starting with the {} tutorial. Make it feel personal and encouraging.', $.accountValidation.username, $.accountValidation.platform, $.accountValidation.preferredGenre, $.tutorialAssignment.tutorialTrackName)"
            }
          ]
        }
      },
      "ResultSelector": {
        "welcomeMessage.$": "$.Body.content[0].text"
      },
      "ResultPath": "$.bedrockWelcome",
      "Catch": [
        {
          "ErrorEquals": ["States.ALL"],
          "ResultPath": "$.bedrockWelcome",
          "Next": "AssignStarterPack"
        }
      ],
      "Next": "AssignStarterPack"
    },
    "AssignStarterPack": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "${AssignStarterPackFunctionArn}",
        "Payload": {
          "playerId.$": "$.accountValidation.playerId",
          "platform.$": "$.accountValidation.platform",
          "experienceLevel.$": "$.accountValidation.experienceLevel"
        }
      },
      "ResultSelector": {
        "packId.$": "$.Payload.packId",
        "items.$": "$.Payload.items",
        "awardedAt.$": "$.Payload.awardedAt"
      },
      "ResultPath": "$.starterPack",
      "Retry": [
        {
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 3,
          "BackoffRate": 2.0
        }
      ],
      "Catch": [
        {
          "ErrorEquals": ["States.ALL"],
          "ResultPath": "$.error",
          "Next": "StarterPackFailed"
        }
      ],
      "Next": "OnboardingComplete"
    },
    "StarterPackFailed": {
      "Type": "Fail",
      "Error": "StarterPackFailed",
      "Cause": "Failed to assign starter pack to new player"
    },
    "OnboardingComplete": {
      "Type": "Succeed"
    }
  }
}
JSON
Expand
100%

Gaming 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