# Step 0: Initialization

## YOUR TASK
Gather workflow requirements and identify triggers before implementing automated processes.

## EXECUTION SEQUENCE

### 1. Identify Workflow Type
- What event triggers this workflow? (user.registered, entity.created, status.changed, time-based)
- What business process should be automated? (email sequence, multi-step approval, notification chain)
- What is the primary action? (SendEmail, Webhook, Condition logic, Wait/delay)
- Is this a new trigger or does it use an existing one? (check WorkflowTriggerConfiguration.cs)

### 2. Define Workflow Variables
- What variables are available from the trigger event?
  - Example: `user.registered` provides userId, email, displayName, confirmUrl
  - Example: `ticket.created` provides ticketId, ticketNumber, title, creatorEmail
- What variables are needed in steps? (recipients, delays, conditions, webhook payloads)
- Map all {{variable}} placeholders to available data

### 3. Plan Workflow Steps
- Step 1: SendEmail? Webhook? Condition? Wait/Delay?
- Step 2: Follow-up action after first step
- Step 3+: Conditional branches or multi-step sequences
- Error handling: what happens if a step fails? (retry, fallback, notify)
- Timeout: should the workflow have a maximum duration?

### 4. Design Email Templates (if SendEmail steps)
- Email subject and body templates
- Handlebars syntax for variable interpolation: `{{userId}}`, `{{confirmUrl}}`
- HTML and plain text versions if needed
- i18n translations: French, English, Italian, German
- Template registration in EmailTemplateConfiguration.cs

### 5. Check Trigger Configuration
- Does the trigger exist in WorkflowTriggerConfiguration.cs?
- If new trigger:
  - Define available variables (JSON serialized array)
  - Add trigger seed data with unique code (kebab-case)
  - Plan where in code to call `IWorkflowService.TriggerAsync(code, variables)`

### 6. Define Logging & Monitoring
- What execution events should be logged?
- How to track workflow success/failure metrics?
- What observability is needed for debugging?

## SUCCESS METRICS
- Workflow trigger identified or new trigger planned
- Available variables from trigger documented
- Workflow steps sequenced (SendEmail -> Wait -> Condition -> Webhook, etc.)
- Email templates designed with i18n
- Trigger configuration understood (existing or new)
- Integration point in code identified (where TriggerAsync is called)
- Error handling strategy defined

## NEXT STEP
Proceed to `./step-01-implementation.md` to implement workflow entity, steps, trigger configuration, email templates, and integration into services with IWorkflowService.
