This example demonstrates a customer onboarding process using Upstash Workflow. The following example workflow registers a new user, sends welcome emails, and periodically checks and responds to the user’s activity state.
We enter an infinite loop to periodically (every month) check the user’s engagement level with our platform and send appropriate emails:
while(true){const state =await context.run("check-user-state",async()=>{returnawaitgetUserState()})if(state ==="non-active"){await context.run("send-email-non-active",async()=>{awaitsendEmail("Email to non-active users", email)})}elseif(state ==="active"){await context.run("send-email-active",async()=>{awaitsendEmail("Send newsletter to active users", email)})}await context.sleep("wait-for-1-month",60*60*24*30)}