SlideShare a Scribd company logo
Harnessing The Power Of AWS Step
Functions To Process Loyalty Customer
Orders
@TheLeePriest
@LeePriest
@TheLeePriest
Who’s this guy!?
Energy Drink Fiend Tech head
Page 1
AWS Community Builder
On The Agenda
• What is LEGO Loyalty?
• A “Loyalty Order”
• The Order Processing Flow
• AWS Step Functions
• How Do We Do It?
• Handling Updates
• Next Steps
Page 2
Page 3
The Loyalty Program
Marketing Channels Technology (MCT)
Page 4
LEGO.com Retail Store Operations Customer Support Centre
Loyalty Service Platform
Page 5
Visits LEGO retail store
Shops at LEGO.com
LEGO Customer
Joins the loyalty membership
Becomes a LEGO VIP
Loyalty Program
Earns loyalty points
Redeems loyalty rewards
Earn Rewards
Completes purchase
Loyalty account updated
In-store Experience
Award Winning!
• Finalist in:
• ‘Customer Analytics, Insights, and
Metrics’
• ‘Offer, Incentive, and Reward Design’
• Clinched the Platinum award!
• Gold in 360-Degree Brand
Page 6
Loyalty Service Platform Overview
Page 7
Loyalty
Customer
LEGO Store Store Till
Loyalty API Existing VIP
Order Placed
Rewards
Loyalty Services
New VIP
LEGO.com
External
applications
Public client
Loyalty Service
Platform
SaaS
CRM
Data
Feeder
Loyalty
Sessions
Event
Bus
Event
Source
Fraud
Engine
Service
Status
Admin
Rewards
Members
SaaS
Survey
LEGO
Data Lake
NPS
Provider
CRM
Service
Orders
Service
Event
Ingestion
Order
Management
LEGO
Event Broker
Page 8
Page 9
A ‘Loyalty’ Order
What Makes a Loyalty VIP Customer Order
• Signed up and verified
• In store or online
• Sale or return
• Rewards
• Vouchers
• Instant redemptions
Page 10
VIP Customer Order Overview
Page 11
Order is
placed by a
VIP member
VIP Order
CRM is updated
with order for the
VIP
CRM
Loyalty API
Loyalty API
receives
order
Order service starts
processing order,
then emits an event
Order Service
Order
Service
CRM Service
CRM Service
picks up event,
communicates
with CRM
CRM
Service
Order Placed
Order placed
and process
complete
Order
Service
Sale Order
• Order item details
• Quantity
• SKU – Product ID
• Price
• Order total
• Earn points
• Rewards
Page 12
VIP Sale Order Processing Overview
Page 13
Handle Rewards
Reward
redemption
and processing is
done and event
emitted
Order Placed
Order place
and process
complete
Service CRM
transforms order
then submits to
order CRM
CRM Service
API Receives
order payload
Loyalty
Service API
Loyalty Service
Lambda Function
Lambda function
performs checks
and emits event
Order service starts
processing. Stores
sale, VIP status
check etc.
Order Service
Return Order
• Return item details
• Quantity
• SKU - Product ID
• Sale order number
• Signed up and verified
• Reallocate points
Page 14
VIP Return Order Processing Overview
Page 15
Handle Rewards
Reward
reallocation
and processing is
done and event
emitted
Order Placed
Order place
and process
complete
Service CRM
transforms order
then submits to
order CRM
Service CRM
API Receives
order payload
Loyalty
Service API
Order service starts
processing. Stores
return, finds
original order etc.
Order Service
Lambda function
performs checks
and emits event
Loyalty Service
Lambda Function
Order Placement Flow
Page 16
Loyalty VIP
Customer
LEGO
Store
Loyalty
API
Order
Placed
Store
Till
Rewards
Selected
Order
Service
Rewards
Applied
Page 17
Sounds Complex!
Sessions
Page 18
Loyalty API
Session Service
Loyalty
Sessions
Loyalty Event Bus
Loyalty Reference Order reference
Merchant reference
Order Processing Flow
Page 19
CRM
CRM
Service
Orders
Service
Order validated
Synchronous response
Orders
Service
Order processed
Customer order
Task Token
“SUCCESS”
Order received
Multiple Resource Access
• Various AWS resources used
• Different services require different resources
• Architectural considerations around how to achieve correct processing flow
Page 20
Summary Of Requirements For Order Handling
#1 Able to handle sync and
async
#2 Handle interacting with
multiple resource types
#3 Communication between
various services
Page 21
Page 22
AWS Step Functions
A Quick Reminder
• Managed Workflow Service
• Built-in error handling
• Built-in state management
• Realtime and auditable workflow execution
history
• Workflow Studio
• And much much more!
Page 23
Workflow Types
Page 24
Standard
• Ideal for long-running workflows
• Can run for up to one year
• Full execution history for up to 90 days
• Billed by state transitions (not duration)
Express
• Ideal for high volume, event-
processing workflows
• Can run for up to five minutes
• Billed by number of executions,
duration of execution and the memory
consumed
Integrate with all the things!
• Direct integration with 220 AWS Services
• Integration run directly in the execution
• Remove ‘integration code’
• Familiar syntax
• Pair with AWS States language
Page 25
Workflow Studio
• Low code
• Visual workflow editor
• Drag and drop
• Auto generates code
• Easily review and export the
generated code
• Export as JSON or YAML
Page 26
Page 27
How Do We Do It?
Storage First Pattern
• Stores order in Dynamo DB
• Logs unique references and execution name
• Runs some checks on payload data
• Starting point of our observability for the VIP
order process
Page 28
Task Tokens are your friend!
• Event is added to event bus with Task Token
• Step Function execution pauses until a response is
received
• Response is either SUCCESS, ERROR or RETRY
• Allows for decoupled microservices to react when
needed
• Task Token handler in separate service
• A ‘Catch’ is used to handle failure responses
Page 29
Task Token Journey
Page 30
Orders
Service
CRM
Service
Orders
Service
CRM
Customer order
Customer rewards
Response status
Acting In Parallel
Page 31
Release
Redeem
Reallocate
Orders
Service
CRM
Service
CRM
Service
CRM
Service
Orders
Service
Why Have A Separate CRM Service?
• Anti-corruption layer
• Point of contact for third party CRM
• Acts as a translation layer between the CRM
and our services
• Other services don’t need to know about
the third party
Page 32
CRM Service
CRM
Let Our Other Services Know
• A sale response event is put on the bus
• Other services can consume the event
and react
Page 33
Error Handling
• Step function catch blocks
• Internal error handler
• Custom middleware
• Capture errors
• Dispatch event
• Structured logs
• Dashboard visibility
Page 34
Testing
• QA Testing
• Integration tests
• Test in real environments
• Tests are run against specific deployed
environments
• Recreation of production environment
Page 35
Page 36
A Moving Landscape
An Always Evolving Process
Page 37
• An order process isn’t static
• Updates to business logic are sometimes needed
• We need to be able to react to and handle things like promotions and special
weekends
• The landscape outside of the Loyalty platform can change
• Third parties can come and go
Handling Non-VIP Orders
Page 38
A Considered Approach
Page 39
Update Checks
Extra checks are needed to
identify VIP vs Non-VIP orders
Observability
Make sure both VIP and Non-
VIP flows are observable
Handle Non-VIP Orders
Processing should be handled in
the same flow as VIP orders
Do Not Disturb
Existing functionality should
not be disturbed
Order Processing Flow
Page 40
CRM
CRM
Service
Orders
Service
Order validated
Synchronous response
Orders
Service
Order processed
Customer order
Task Token
“SUCCESS”
Order received
Express Solution
Page 41
• A separate express step function
• Able to run synchronously using
StartSyncExecution
• VTL to configure request and response
• Executes before the existing order process step
function
• Short, fast execution
• Cheap to run
Order Check Step Function
• Simple and effective
• VIP and Non-VIP specific paths
• One Lambda Function per path
• Lambda function emits an event
that triggers the larger order step
function
• Separate error handling
Page 42
A Look at the Payloads
Page 43
VIP Non-VIP
Updates to the Order Step Function
• A new choice state checks the presence of a
variable
• No disturbance to existing flow
• New choice state allows for an entirely
separate flow
• We store the Non-VIP order as we do in the
VIP flow
Page 44
Updated Order Processing Flow
Page 45
CRM
CRM
Service
Orders
Service
Order validated
Synchronous response
Orders
Service
Order processed
Customer order
Task Token
“SUCCESS”
Order received
What Made This Approach Work?
Page 46
• Work could be done in parallel
• Existing functionality was not disturbed
• Changes made to existing Lambda functions were minimal
• Deployment confidence
• Independent piece deployment
• A single choice step allowed for a fully separate flow for Non-VIP handling
Page 47
Where Next?
It’s Not Perfect…Yet
• The main order step function is huge!
• Extra traffic to the flow opens up space
for improvements
• Error handling can be extended further
Page 48
Where we’re looking to improve
#1 Re-factor to include nested
express workflows
#2 Split VIP and Non-VIP in to
separate Step Functions
#3 Make more use of SDK
integrations
Page 49
Page 50
That’s All Folks!
Page 51
Where You Can Find Me
Medium
@leepriest
Github
@TheLeePriest
Twitter
@TheLeePriest
Come say hi at the community booth at 15:30!

More Related Content

What's hot

Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC WongDocker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker, Inc.
 

What's hot (20)

Microservices
MicroservicesMicroservices
Microservices
 
Circuit Breaker Pattern
Circuit Breaker PatternCircuit Breaker Pattern
Circuit Breaker Pattern
 
Amazon ECS
Amazon ECSAmazon ECS
Amazon ECS
 
How to Grow a Serverless Team in an Enterprise
How to Grow a Serverless Team in an EnterpriseHow to Grow a Serverless Team in an Enterprise
How to Grow a Serverless Team in an Enterprise
 
Migrating from oracle soa suite to microservices on kubernetes
Migrating from oracle soa suite to microservices on kubernetesMigrating from oracle soa suite to microservices on kubernetes
Migrating from oracle soa suite to microservices on kubernetes
 
Azure DevOps
Azure DevOpsAzure DevOps
Azure DevOps
 
Observability
ObservabilityObservability
Observability
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)
 
IT Infrastructure Automation with Ansible
IT Infrastructure Automation with AnsibleIT Infrastructure Automation with Ansible
IT Infrastructure Automation with Ansible
 
Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC WongDocker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Capital One DevOps Case Study: A Bank with the Heart of Tech Company
Capital One DevOps Case Study: A Bank with the Heart of Tech CompanyCapital One DevOps Case Study: A Bank with the Heart of Tech Company
Capital One DevOps Case Study: A Bank with the Heart of Tech Company
 
Kafka: Uma introdução para Desenvolvedores e Arquitetos
 Kafka: Uma introdução para Desenvolvedores e Arquitetos Kafka: Uma introdução para Desenvolvedores e Arquitetos
Kafka: Uma introdução para Desenvolvedores e Arquitetos
 
API first Design and Microservices
API first Design and MicroservicesAPI first Design and Microservices
API first Design and Microservices
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to Testcontainers
 
Red Hat Openshift on Microsoft Azure
Red Hat Openshift on Microsoft AzureRed Hat Openshift on Microsoft Azure
Red Hat Openshift on Microsoft Azure
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Rabbit MQ introduction
Rabbit MQ introductionRabbit MQ introduction
Rabbit MQ introduction
 
Architecting Cloud Applications - the essential checklist
Architecting Cloud Applications - the essential checklistArchitecting Cloud Applications - the essential checklist
Architecting Cloud Applications - the essential checklist
 

Similar to Harnessing The Power Of AWS Step Functions To Process Loyalty Customer Orders

Client on-boarding
Client on-boardingClient on-boarding
Client on-boarding
Doxim Inc.
 
Why software testing
Why software testingWhy software testing
Why software testing
transformtoit
 
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Amazon Web Services
 
DEMO_Redfaire AP Automation SHORT
DEMO_Redfaire AP Automation SHORTDEMO_Redfaire AP Automation SHORT
DEMO_Redfaire AP Automation SHORT
Stuart McDonnell
 
InvisibleCRM Reselling Partner Program
InvisibleCRM Reselling Partner ProgramInvisibleCRM Reselling Partner Program
InvisibleCRM Reselling Partner Program
InvisibleCRM
 

Similar to Harnessing The Power Of AWS Step Functions To Process Loyalty Customer Orders (20)

Save Time and Resources - Fully Automate Intercompany Process End to End
Save Time and Resources - Fully Automate Intercompany Process End to EndSave Time and Resources - Fully Automate Intercompany Process End to End
Save Time and Resources - Fully Automate Intercompany Process End to End
 
MivaCon 15 Keynote
MivaCon 15 KeynoteMivaCon 15 Keynote
MivaCon 15 Keynote
 
Client on-boarding
Client on-boardingClient on-boarding
Client on-boarding
 
Oracle apps r12 scm functional training
Oracle apps r12 scm functional trainingOracle apps r12 scm functional training
Oracle apps r12 scm functional training
 
QuickBooks Desktop: Going Out of Style Like VHS Tapes
QuickBooks Desktop: Going Out of Style Like VHS TapesQuickBooks Desktop: Going Out of Style Like VHS Tapes
QuickBooks Desktop: Going Out of Style Like VHS Tapes
 
Why software testing
Why software testingWhy software testing
Why software testing
 
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
 
Netmera_Presentation.pdf
Netmera_Presentation.pdfNetmera_Presentation.pdf
Netmera_Presentation.pdf
 
zed Vendor Portal for SAP Business One
zed Vendor Portal for SAP Business Onezed Vendor Portal for SAP Business One
zed Vendor Portal for SAP Business One
 
How SunTec India elevated the sales of an eCommerce business by automating mu...
How SunTec India elevated the sales of an eCommerce business by automating mu...How SunTec India elevated the sales of an eCommerce business by automating mu...
How SunTec India elevated the sales of an eCommerce business by automating mu...
 
DEMO_Redfaire AP Automation SHORT
DEMO_Redfaire AP Automation SHORTDEMO_Redfaire AP Automation SHORT
DEMO_Redfaire AP Automation SHORT
 
E Commerce: Its role and development
E Commerce: Its role and developmentE Commerce: Its role and development
E Commerce: Its role and development
 
SPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersSPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event Handlers
 
ECM Renovation Roadshow: Automation Systems
ECM Renovation Roadshow:  Automation SystemsECM Renovation Roadshow:  Automation Systems
ECM Renovation Roadshow: Automation Systems
 
Evolve 2014 experience driven commerce
Evolve 2014 experience driven commerceEvolve 2014 experience driven commerce
Evolve 2014 experience driven commerce
 
Optimize application performance - Mumbai Seminar
Optimize application performance - Mumbai Seminar Optimize application performance - Mumbai Seminar
Optimize application performance - Mumbai Seminar
 
InvisibleCRM Reselling Partner Program
InvisibleCRM Reselling Partner ProgramInvisibleCRM Reselling Partner Program
InvisibleCRM Reselling Partner Program
 
Travel Technology Europe 2013 - How to Execute a Successful E-Commerce Strate...
Travel Technology Europe 2013 - How to Execute a Successful E-Commerce Strate...Travel Technology Europe 2013 - How to Execute a Successful E-Commerce Strate...
Travel Technology Europe 2013 - How to Execute a Successful E-Commerce Strate...
 
2019 DACH Roadshow - Workflow Automation in Microservices Architectures
2019 DACH Roadshow - Workflow Automation in Microservices Architectures2019 DACH Roadshow - Workflow Automation in Microservices Architectures
2019 DACH Roadshow - Workflow Automation in Microservices Architectures
 
The Digital Innovation Award - Ignatica
The Digital Innovation Award - IgnaticaThe Digital Innovation Award - Ignatica
The Digital Innovation Award - Ignatica
 

Recently uploaded

Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 

Recently uploaded (20)

AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 

Harnessing The Power Of AWS Step Functions To Process Loyalty Customer Orders

  • 1. Harnessing The Power Of AWS Step Functions To Process Loyalty Customer Orders @TheLeePriest @LeePriest @TheLeePriest
  • 2. Who’s this guy!? Energy Drink Fiend Tech head Page 1 AWS Community Builder
  • 3. On The Agenda • What is LEGO Loyalty? • A “Loyalty Order” • The Order Processing Flow • AWS Step Functions • How Do We Do It? • Handling Updates • Next Steps Page 2
  • 5. Marketing Channels Technology (MCT) Page 4 LEGO.com Retail Store Operations Customer Support Centre
  • 6. Loyalty Service Platform Page 5 Visits LEGO retail store Shops at LEGO.com LEGO Customer Joins the loyalty membership Becomes a LEGO VIP Loyalty Program Earns loyalty points Redeems loyalty rewards Earn Rewards Completes purchase Loyalty account updated In-store Experience
  • 7. Award Winning! • Finalist in: • ‘Customer Analytics, Insights, and Metrics’ • ‘Offer, Incentive, and Reward Design’ • Clinched the Platinum award! • Gold in 360-Degree Brand Page 6
  • 8. Loyalty Service Platform Overview Page 7 Loyalty Customer LEGO Store Store Till Loyalty API Existing VIP Order Placed Rewards Loyalty Services New VIP LEGO.com External applications
  • 11. What Makes a Loyalty VIP Customer Order • Signed up and verified • In store or online • Sale or return • Rewards • Vouchers • Instant redemptions Page 10
  • 12. VIP Customer Order Overview Page 11 Order is placed by a VIP member VIP Order CRM is updated with order for the VIP CRM Loyalty API Loyalty API receives order Order service starts processing order, then emits an event Order Service Order Service CRM Service CRM Service picks up event, communicates with CRM CRM Service Order Placed Order placed and process complete Order Service
  • 13. Sale Order • Order item details • Quantity • SKU – Product ID • Price • Order total • Earn points • Rewards Page 12
  • 14. VIP Sale Order Processing Overview Page 13 Handle Rewards Reward redemption and processing is done and event emitted Order Placed Order place and process complete Service CRM transforms order then submits to order CRM CRM Service API Receives order payload Loyalty Service API Loyalty Service Lambda Function Lambda function performs checks and emits event Order service starts processing. Stores sale, VIP status check etc. Order Service
  • 15. Return Order • Return item details • Quantity • SKU - Product ID • Sale order number • Signed up and verified • Reallocate points Page 14
  • 16. VIP Return Order Processing Overview Page 15 Handle Rewards Reward reallocation and processing is done and event emitted Order Placed Order place and process complete Service CRM transforms order then submits to order CRM Service CRM API Receives order payload Loyalty Service API Order service starts processing. Stores return, finds original order etc. Order Service Lambda function performs checks and emits event Loyalty Service Lambda Function
  • 17. Order Placement Flow Page 16 Loyalty VIP Customer LEGO Store Loyalty API Order Placed Store Till Rewards Selected Order Service Rewards Applied
  • 19. Sessions Page 18 Loyalty API Session Service Loyalty Sessions Loyalty Event Bus Loyalty Reference Order reference Merchant reference
  • 20. Order Processing Flow Page 19 CRM CRM Service Orders Service Order validated Synchronous response Orders Service Order processed Customer order Task Token “SUCCESS” Order received
  • 21. Multiple Resource Access • Various AWS resources used • Different services require different resources • Architectural considerations around how to achieve correct processing flow Page 20
  • 22. Summary Of Requirements For Order Handling #1 Able to handle sync and async #2 Handle interacting with multiple resource types #3 Communication between various services Page 21
  • 23. Page 22 AWS Step Functions
  • 24. A Quick Reminder • Managed Workflow Service • Built-in error handling • Built-in state management • Realtime and auditable workflow execution history • Workflow Studio • And much much more! Page 23
  • 25. Workflow Types Page 24 Standard • Ideal for long-running workflows • Can run for up to one year • Full execution history for up to 90 days • Billed by state transitions (not duration) Express • Ideal for high volume, event- processing workflows • Can run for up to five minutes • Billed by number of executions, duration of execution and the memory consumed
  • 26. Integrate with all the things! • Direct integration with 220 AWS Services • Integration run directly in the execution • Remove ‘integration code’ • Familiar syntax • Pair with AWS States language Page 25
  • 27. Workflow Studio • Low code • Visual workflow editor • Drag and drop • Auto generates code • Easily review and export the generated code • Export as JSON or YAML Page 26
  • 28. Page 27 How Do We Do It?
  • 29. Storage First Pattern • Stores order in Dynamo DB • Logs unique references and execution name • Runs some checks on payload data • Starting point of our observability for the VIP order process Page 28
  • 30. Task Tokens are your friend! • Event is added to event bus with Task Token • Step Function execution pauses until a response is received • Response is either SUCCESS, ERROR or RETRY • Allows for decoupled microservices to react when needed • Task Token handler in separate service • A ‘Catch’ is used to handle failure responses Page 29
  • 31. Task Token Journey Page 30 Orders Service CRM Service Orders Service CRM Customer order Customer rewards Response status
  • 32. Acting In Parallel Page 31 Release Redeem Reallocate Orders Service CRM Service CRM Service CRM Service Orders Service
  • 33. Why Have A Separate CRM Service? • Anti-corruption layer • Point of contact for third party CRM • Acts as a translation layer between the CRM and our services • Other services don’t need to know about the third party Page 32 CRM Service CRM
  • 34. Let Our Other Services Know • A sale response event is put on the bus • Other services can consume the event and react Page 33
  • 35. Error Handling • Step function catch blocks • Internal error handler • Custom middleware • Capture errors • Dispatch event • Structured logs • Dashboard visibility Page 34
  • 36. Testing • QA Testing • Integration tests • Test in real environments • Tests are run against specific deployed environments • Recreation of production environment Page 35
  • 37. Page 36 A Moving Landscape
  • 38. An Always Evolving Process Page 37 • An order process isn’t static • Updates to business logic are sometimes needed • We need to be able to react to and handle things like promotions and special weekends • The landscape outside of the Loyalty platform can change • Third parties can come and go
  • 40. A Considered Approach Page 39 Update Checks Extra checks are needed to identify VIP vs Non-VIP orders Observability Make sure both VIP and Non- VIP flows are observable Handle Non-VIP Orders Processing should be handled in the same flow as VIP orders Do Not Disturb Existing functionality should not be disturbed
  • 41. Order Processing Flow Page 40 CRM CRM Service Orders Service Order validated Synchronous response Orders Service Order processed Customer order Task Token “SUCCESS” Order received
  • 42. Express Solution Page 41 • A separate express step function • Able to run synchronously using StartSyncExecution • VTL to configure request and response • Executes before the existing order process step function • Short, fast execution • Cheap to run
  • 43. Order Check Step Function • Simple and effective • VIP and Non-VIP specific paths • One Lambda Function per path • Lambda function emits an event that triggers the larger order step function • Separate error handling Page 42
  • 44. A Look at the Payloads Page 43 VIP Non-VIP
  • 45. Updates to the Order Step Function • A new choice state checks the presence of a variable • No disturbance to existing flow • New choice state allows for an entirely separate flow • We store the Non-VIP order as we do in the VIP flow Page 44
  • 46. Updated Order Processing Flow Page 45 CRM CRM Service Orders Service Order validated Synchronous response Orders Service Order processed Customer order Task Token “SUCCESS” Order received
  • 47. What Made This Approach Work? Page 46 • Work could be done in parallel • Existing functionality was not disturbed • Changes made to existing Lambda functions were minimal • Deployment confidence • Independent piece deployment • A single choice step allowed for a fully separate flow for Non-VIP handling
  • 49. It’s Not Perfect…Yet • The main order step function is huge! • Extra traffic to the flow opens up space for improvements • Error handling can be extended further Page 48
  • 50. Where we’re looking to improve #1 Re-factor to include nested express workflows #2 Split VIP and Non-VIP in to separate Step Functions #3 Make more use of SDK integrations Page 49
  • 52. Page 51 Where You Can Find Me Medium @leepriest Github @TheLeePriest Twitter @TheLeePriest Come say hi at the community booth at 15:30!