Build Temporal Workflow System

backend
TypeScript
architecture
strict_senior
Remix

Create reliable distributed workflows with activities, signals, and error handling.

12/8/2025

Prompt

Build a complete Temporal workflow orchestration system for [WORKFLOW_NAME] with the following specifications:

Requirements

  • Workflow name: [WORKFLOW_NAME]
  • Business process: [PROCESS_DESCRIPTION]
  • Workflow steps: [STEP_1], [STEP_2], [STEP_3], [STEP_4]
  • Activities needed: [ACTIVITY_1], [ACTIVITY_2], [ACTIVITY_3]
  • External services to call: [SERVICE_1], [SERVICE_2]
  • Task queue name: [QUEUE_NAME]
  • Timeout requirements: [ACTIVITY_TIMEOUT], [WORKFLOW_TIMEOUT]
  • Retry policies: [MAX_ATTEMPTS], [BACKOFF_STRATEGY]
  • Signals to support: [SIGNAL_1], [SIGNAL_2]
  • Queries to support: [QUERY_1], [QUERY_2]
  • Error handling strategy: [COMPENSATE/RETRY/FAIL]

Deliverables

Generate complete Temporal workflow code with:

Workflow definition file:

  • Main workflow function for [WORKFLOW_NAME]
  • Activity proxies with timeout configuration
  • Step-by-step orchestration of [STEPS]
  • Error handling for each activity
  • Conditional logic for business rules
  • Compensation logic if errors occur
  • Signal handlers for [SIGNALS]
  • Query handlers for [QUERIES]
  • TypeScript types for workflow inputs/outputs

Activities file with implementations:

  • Activity function for each [ACTIVITY]
  • External service integrations for [SERVICES]
  • Database operations
  • API calls with proper error handling
  • Idempotent activity design
  • Activity heartbeats for long-running tasks
  • TypeScript types for activity params/results

Worker setup:

  • Worker.create() with configuration
  • Workflow path registration
  • Activities registration
  • Task queue: [QUEUE_NAME]
  • Concurrent workflow/activity limits
  • Worker shutdown handling
  • Connection to Temporal server

Client code:

  • Temporal Client initialization
  • Workflow start with workflowId generation
  • Pass workflow arguments
  • Handle workflow result
  • Send signals to running workflows
  • Query workflow state
  • Cancel/terminate workflows
  • Error handling for client operations

Signal handlers for [SIGNALS]:

  • defineSignal() declarations
  • setHandler() implementations
  • State management in workflow
  • Signal validation

Query handlers for [QUERIES]:

  • defineQuery() declarations
  • setHandler() implementations
  • Return current workflow state

Retry and timeout configuration:

  • Activity retry policies with [MAX_ATTEMPTS]
  • Exponential backoff: [BACKOFF_STRATEGY]
  • Activity timeouts: [ACTIVITY_TIMEOUT]
  • Workflow timeouts: [WORKFLOW_TIMEOUT]
  • Non-retryable error types

Type definitions:

  • Workflow input/output types
  • Activity parameter types
  • Signal payload types
  • Query response types

Output production-ready Temporal workflows with proper error handling and observability.

Tags

temporal
workflow
orchestration
distributed-systems

Tested Models

gpt-4-turbo
claude-3-opus

Comments (0)

Sign in to leave a comment

Sign In