# Reusability

Reusability means designing flows, Say nodes, and routing logic once and using them across multiple journeys—instead of copying and pasting.

Build once → reuse everywhere

#### YAML Anchors & Aliases

YAML **anchors** (`&`) let you **define a block once**.\
YAML **aliases** (`*`) let you **reuse that block elsewhere**.

Think of them as **copy‑by‑reference for YAML blocks**.

Use YAML's native reuse mechanism:

```
nodes:    
      - api_call_1:    
          type: api    
          integration: API1    
          method: method1    
          exits:    
            success:    
              next: next1    
            failure:    
              next: api_failure # Route to shared error node    
         
      - api_call_2:    
          type: api    
          integration: API2    
          method: method2    
          exits:    
            success:    
              next: next2    
            failure:    
              next: api_failure # Same error node    
         
      # Shared error handling node    
      - api_failure:    
          type: say    
          message: I couldn't reach our systems. Let me connect you with someone.    
          next: transfer_agent   
```

#### Node Inheritance (Standard YAML Feature)

YAML does **not** have true object‑oriented inheritance, this uses native YAML anchors (\&name) and merge keys (<<: \*name) - not YFlow-specific syntax.

* **Anchors (`&`)**
* **Aliases (`*`)**
* **Merge key (`<`)**

Together, these allow one node to **inherit properties from another node and override only what’s different**.

Optional, but useful for reducing repetition:

```
    # Base definitions    
    bases:    
      standard_agent: &standard_agent    
        type: agent    
        iteration_limit: 5    
        fallback: *error_recovery    
         
    nodes:    
      - sales_agent:    
          <<: *standard_agent       # Inherit base    
          system: You help with sales inquiries.    
          goals:    
            quote:    
              description: User wants a price quote    
              next: generate_quote    
            done:    
              description: User is finished    
              next: end    
         
      - support_agent:    
          <<: *standard_agent       # Same base    
          system: You help with technical support.    
          goals:    
            ticket:    
              description: User needs a support ticket    
              next: create_ticket    
            done:    
              description: User is finished    
              next: end    
```

### Components

Components are fully specified but deferred to a future implementation spike. See\
**YFLOW\_SPEC\_COMPONENTS.md** for the complete component design\
including:

* Component definition (entries/exits with typed variables)
* Component node (type: component) with variable mapping
* Execution isolation (own variable space and LLM memory)
* Routing syntax (next: node:entry, exit:name)
* Customer v2 data structure mapping
* Say Node future enhancements (voice override, speed, i18n)


---

# 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.ixhello.com/ixhc2/technical-specifications/yflow-a-yaml-based-conversational-flow-language/reusability.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.
