using Elsa.Extensions; using Elsa.Workflows.Core.Activities; using Elsa.Workflows.Core.Models; using Elsa.Workflows.Core.Services; using Microsoft.Extensions.DependencyInjection; // Setup service container. var services = new ServiceCollection(); // Add Elsa services. services.AddElsa(); // Build service container. var serviceProvider = services.BuildServiceProvider(); // Create a workflow. var nameVariable = new Variable(); // Define a simple sequential workflow: var workflow = new Sequence { // Register the name variable. Variables = { nameVariable }, // Setup the sequence of activities to run. Activities = { new WriteLine("Please tell me your name:"), new ReadLine(nameVariable), new WriteLine(context => $"Nice to meet you, {nameVariable.Get(context)}!") } }; // Resolve a workflow runner to run the workflow. var workflowRunner = serviceProvider.GetRequiredService(); // Run the workflow. await workflowRunner.RunAsync(workflow);