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.