> ## Documentation Index
> Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mapping inputs and outputs

You can manually map the inputs and outputs of your nodes using the `map_input()` and `map_output()` methods. To do this, call `map_input()` or `map_output()` in your node and provide the following values:

<Expandable title="`map_input()` Parameters">
  <ParamField path="input_variable" type="string" required="true">
    The variable you want to map.
  </ParamField>

  <ParamField path="expression" type="string" required="true">
    The expression used to map the input.
  </ParamField>

  <ParamField path="default_value" type="string" required="false">
    The default value for the mapped input.
  </ParamField>
</Expandable>

<Expandable title="`map_output()` Parameters">
  <ParamField path="output_variable" type="string" required="true">
    The variable you want to map.
  </ParamField>

  <ParamField path="expression" type="string" required="true">
    The expression used to map the output.
  </ParamField>

  <ParamField path="default_value" type="string" required="false">
    The default value for the mapped output.
  </ParamField>
</Expandable>

The following example shows how to use `map_input()` and `map_output()` to map values for a node:

```py Python [expandable] theme={null}
'''
Build a simple hello world agentic workflow that will combine the result of two tools.
'''

from pydantic import BaseModel
from ibm_watsonx_orchestrate.flow_builder.flows import END, Flow, flow, START

from .get_hello_message import get_hello_message
from .combine_names import combine_names

class Name(BaseModel):
    """
    This class represents a person's name.

    Attributes:
        first_name (str): The person's first name.
        last_name (str): The person's last name.
    """
    first_name: str
    last_name: str

class Message(BaseModel):
    msg: str

@flow(
        name = "hello_message_flow",
        input_schema=Name,
        output_schema=Message
    )
def build_hello_message_flow_datamap(aflow: Flow = None) -> Flow:
    """
    Creates an agentic workflow with two tools: get_hello_message and combine_names.
    Args:
        flow (Flow, optional): The agentic workflow to be built. Defaults to None.
    Returns:
        Flow: The created agentic workflow.
    """
    combine_names_node = aflow.tool(combine_names)
    combine_names_node.map_input(input_variable="first_name", expression="flow.input.first_name")
    combine_names_node.map_input(input_variable="last_name", expression="flow.input.last_name", default_value="default_last_name")

    get_hello_message_node = aflow.tool(get_hello_message, output_schema=Message)

    aflow.edge(START, combine_names_node).edge(combine_names_node, get_hello_message_node).edge(get_hello_message_node, END)

flow.map_output(
    output_variable="Type_Justification",
    expression="flow.Type_Classifier_Node.output.justification_text if flow.Classifier_Node.output.justification_text else \"N/A\"")
             
    return aflow
```

Nodes use schemas to define the structure of incoming and outgoing data, ensuring consistent validation and predictable behavior. The following parameters describe how schemas and mapping functions control the flow of data through a node.

<Expandable title="Schema definitions and data mapping Parameters">
  <ParamField path="input_schema" type="string" required>
    Defines the structure and types of the data a node expects to receive, acting as the contract for all required and optional inputs.
  </ParamField>

  <ParamField path="map_input" type="string" required>
    Binds incoming data to the node’s internal parameters using the input schema, optionally transforming or defaulting values.
  </ParamField>

  <ParamField path="output_schema" type="string" required>
    Specifies the structured format and types of the data the node will return after execution.
  </ParamField>

  <ParamField path="map_output" type="string" required>
    Constructs the final output object according to the output schema by mapping internal execution results into the defined fields.
  </ParamField>
</Expandable>

The following example shows how a node applies its schema definitions and mapping parameters to process inputs and generate a structured, validated output.

```py Python [expandable] theme={null}

class GEN_AI_NODE(BaseModel):
    description_original: str = Field(description="Formatted description ....", default="")

class JUSTIFICATION_TYPE_RESULT(BaseModel):
    grievance_type_llm: str = Field(description="Type of thing", default="")
    justification_text: str = Field(description="Justification for classified type", default="")

classifier_node = flow.prompt(
      name="Classifier_Node",
      display_name="Classifier_Node",
      description="Type Classifier",
      ...
      input_schema=GEN_AI_NODE,
      output_schema=JUSTIFICATION_TYPE_RESULT)

classifier_node.map_input(input_variable="description_original", expression="flow.Load_Extracted_Data_Node.output.extracted_kvps.Description_Original")
```
