WJb Docs - Intermediate

Learn workflows, persistence, scheduling, and production-ready patterns.

πŸš€ Start Here
🧩 Mental Model
🌊 Building Workflows
πŸ’₯ Failures & Control
πŸ‘€ Observation & Debugging
πŸ›  Practical Patterns
βœ… Working Examples
➑️ What’s Next

πŸ“₯ Data Enrichment

Data enrichment is the pattern where an action loads or calculates additional information and passes the richer data to the next step.

Raw Input
   ↓
Enrichment Action
   ↓
Enriched Data
   ↓
Next Action

Basic Example

[ActionName("load-customer")]
public sealed class LoadCustomerAction : JobAction<OrderInput>
{
    public override async Task<IActionResult> ExecuteAsync(
        OrderInput input, CancellationToken ct)
    {
        var customer = await _customers.GetByIdAsync(input.CustomerId, ct);

return await NextAsync<ProcessOrderAction>( new ProcessOrderInput { OrderId = input.OrderId, Customer = customer, // enriched data Items = input.Items }); } }

The next action receives both the original information and the newly loaded customer data.


Multi-step Enrichment

You can enrich data gradually:

Import raw records
      ↓
Enrich with customer info
      ↓
Enrich with pricing
      ↓
Process

Each action adds only what is needed for the following steps.


Example with External Service

public override async Task<IActionResult> ExecuteAsync(
    UserInput input, CancellationToken ct)
{
    var profile = await _externalApi.GetProfileAsync(input.UserId, ct);
    var preferences = await _preferences.GetAsync(input.UserId, ct);

return await NextAsync<SendPersonalizedEmailAction>( new EmailContext { UserId = input.UserId, Email = profile.Email, Name = profile.FullName, Preferences = preferences }); }


Best Practices

  • Enrich only the data that the next actions actually need
  • Keep payloads focused β€” do not pass the entire database entity if only a few fields are required
  • Prefer small, purpose-built models for each step
  • Handle missing data explicitly (throw or take a different path)
  • Consider caching when enrichment calls are expensive

When to Use Data Enrichment

Use this pattern when:

  • The initial payload contains only identifiers
  • Later steps need additional details from a database or external service
  • You want to keep early actions lightweight
  • You need to transform or normalize data before processing

Key Point

Enrichment is just an action that loads extra information and passes a richer payload to the next action.

It keeps data flow explicit and makes each step self-contained.

An unhandled error has occurred. Reload πŸ—™

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.