# Document Creation Node

### Overview

The Document Creation Node creates new document objects with custom content and metadata for use within your flow. This node is particularly valuable for generating structured documents, preparing content for vector storage, or creating formatted output with rich metadata. It supports dynamic content generation through variable interpolation in both content and metadata fields.

**Usage cost:** 0 credit

### Configuration

#### Settings

**Content Configuration**

* **Document Content**\* (text area): The main text content of the document
  * Supports variable interpolation using standard syntax
  * Can include multi-line content with formatting
  * Example: `"Customer inquiry: ${user_message}\n\nResponse: ${ai_response}"`

**Metadata Configuration**

* **Document Metadata** (dynamic fields): Custom metadata key-value pairs
  * **Add Metadata** button to create new metadata fields
  * Each field has:
    * **Key** (text): Metadata field name (supports variable interpolation)
    * **Value** (text): Metadata field value (supports variable interpolation)
  * Common metadata examples:
    * `source`: Where the content originated
    * `timestamp`: When the document was created
    * `author`: Who created or processed the content
    * `tags`: Classification or categorization tags
    * `version`: Document version or iteration

### Output Ports

* `document` (Document): The created document object
  * Contains the interpolated content as the main text
  * Includes all specified metadata fields
  * Compatible with document processing and vector storage nodes

### Best Practices

#### **Content Structure**

* Use clear, well-formatted content templates for consistency
* Include relevant context and variable interpolation for dynamic content
* Consider downstream processing requirements when structuring content

#### **Metadata Design**

* Use standardized metadata field names across your application
* Include essential information like source, timestamp, and categorization
* Leverage variable interpolation for dynamic metadata values

#### **Variable Management**

* Ensure all referenced variables are available from previous nodes
* Test with various input scenarios to verify proper interpolation
* Handle potential null/missing variables gracefully in templates

#### **Document Organization**

* Create consistent document structures for similar content types
* Use metadata for searchability and filtering in downstream processes
* Consider document lifecycle and versioning in metadata design

### Common Issues

* **Variable interpolation failures** - Verify all referenced variables exist and have expected values
* **Empty metadata keys** - Ensure metadata key fields are not empty or resolve to blank values
* **Content formatting** - Check that variable interpolation produces properly formatted content
* **Metadata type consistency** - Maintain consistent data types for similar metadata fields across documents


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.waterflai.ai/studio/studio-builders/flow-components-nodes/document-creation-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
