Skip to Content
DocumentationBuilt-In ToolsCore ModuleCreateDocument

CreateDocument

The CreateDocument tool allows you to create structured documents that are rendered as interactive forms in the Loopstack Studio frontend. This is the primary way to handle structured data input and output in your workflows.

Documents created with CreateDocument are displayed as forms in the Loopstack Studio:

Basic Usage

Simple Document Creation

transitions: - id: create_form from: start to: waiting_for_response call: - tool: CreateDocument args: document: MeetingNotesDocument update: content: text: "Initial meeting notes..."

With Validation

transitions: - id: create_validated_doc from: start to: processing call: - tool: CreateDocument args: document: OptimizedNotesDocument validate: strict update: content: date: "2025-01-15" summary: "Team meeting summary" participants: ["Alice", "Bob"]

Validation Modes

  • strict (default): Throws an error and stops workflow execution if validation fails
  • safe: Marks the document as having an error but allows workflow execution to continue
  • skip: Skips validation entirely (use with caution)

Complete Example

import { z } from 'zod'; import { BlockConfig } from '@loopstack/shared'; import { Document, CreateDocument } from '@loopstack/core'; import { Expose } from 'class-transformer'; @BlockConfig({ properties: z.object({ title: z.string(), description: z.string(), priority: z.enum(['low', 'medium', 'high']), }), configFile: __dirname + '/task-document.yaml', }) export class TaskDocument extends Document { @Expose() title: string; @Expose() description: string; @Expose() priority: 'low' | 'medium' | 'high'; }
# task-document.yaml ui: properties: title: title: Task Title description: title: Description widget: textarea priority: title: Priority widget: select
# workflow.yaml transitions: - id: create_task from: start to: task_created call: - tool: CreateDocument args: document: TaskDocument validate: strict update: content: title: "Review documentation" description: "Review and update API docs" priority: "high" tags: ["documentation", "review"]

Working with User Input

Combine CreateDocument with manual transitions to capture user input:

transitions: - id: show_form from: start to: awaiting_input call: - tool: CreateDocument args: document: MeetingNotesDocument update: content: text: "Enter your meeting notes here..." - id: capture_input from: awaiting_input to: processing when: manual call: - tool: CreateDocument args: document: MeetingNotesDocument update: content: ${ ctx.payload.transition.payload }
Last updated on