> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-preview-yajing-marketplace-doc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Lesson 9: Layout Designer (Template)

In Lesson 8, we simplified the workflow to one Product Support Agent.

The content may be accurate and well written, but generated formatting can still vary. A greeting may change, a divider may disappear, or a signature may be phrased differently from one run to the next.

For elements that must remain consistent, we can use a Template node.

## Template

It takes the original data (like your list of answers), follows a strict design template/standards you provide, and generates a perfectly formatted block of text, ensuring consistency every single time.

## Hands-On: Polish the Email Layout

<Steps>
  <Step title="Check the Product Support Agent">
    Select **Product Support** on the workflow canvas. Its assignment should require it to handle the complete email but return only the substantive body. Add the text below in **Agent task**:

    ```text wrap theme={null}
    Return the body only, without a greeting, divider, or signature.
    ```

    This separation matters: the Agent controls delivery and tone, while the Template controls the fixed layout.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8-preview-yajing-marketplace-doc/sPaesDqCRjA9finA/images/use-dify/tutorial/workflow-101-lesson-09/update-agent-task.png?fit=max&auto=format&n=sPaesDqCRjA9finA&q=85&s=ee942f20deaef04fc195b231e2a656a9" alt="Add the Body-Only Rule to Agent Task" width="1114" height="866" data-path="images/use-dify/tutorial/workflow-101-lesson-09/update-agent-task.png" />
    </Frame>
  </Step>

  <Step title="Add a Template Node">
    Insert a Template node after the Agent node and before Output.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8-preview-yajing-marketplace-doc/sPaesDqCRjA9finA/images/use-dify/tutorial/workflow-101-lesson-09/template-node.png?fit=max&auto=format&n=sPaesDqCRjA9finA&q=85&s=80afadcf760646fba7b7b12589cf8ab5" alt="Insert a Template Node Before Output" width="2130" height="482" data-path="images/use-dify/tutorial/workflow-101-lesson-09/template-node.png" />
    </Frame>
  </Step>

  <Step title="Set the Input Variables">
    Open the Template node and add these variables:

    * `customer`: `User Input /{x} customer_name`
    * `body`: `Agent /{x} text`

    Using the Agent's `text` output makes the handoff easy to understand and inspect.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8-preview-yajing-marketplace-doc/sPaesDqCRjA9finA/images/use-dify/tutorial/workflow-101-lesson-09/add-input-variable.png?fit=max&auto=format&n=sPaesDqCRjA9finA&q=85&s=4124ad08988bcf209b6703752452bf61" alt="Add the Customer and Body Variables" width="1770" height="530" data-path="images/use-dify/tutorial/workflow-101-lesson-09/add-input-variable.png" />
    </Frame>
  </Step>

  <Step title="Format the Email with Jinja">
    **What is Jinja2?**

    In simple terms, Jinja2 is a tool that allows you to format variables (like your list of answers) into a text template exactly how you want. It uses simple symbols to mark where variables go and perform basic logic. With it, we can turn a raw list of data into a neat, standardized text block.

    Here, we can put together opening, signatures, and email body to make sure the email is professional and consistent every time.

    Copy and paste this exact layout into the Template code box:

    ```text wrap theme={null}
    Hi {{ customer }},

    Thank you for reaching out. We are happy to help with your questions.

    {{ body }}

    ---
    Best regards,
    Dify Support Team
    ```

    The values of `customer` and `body` can change with every workflow run. Everything around them remains fixed. This gives the Agent freedom to write the answer while ensuring that the final email always follows the required layout.
  </Step>

  <Step title="Update the Output Node">
    Open Output. Replace the previous value with the Template node's output.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8-preview-yajing-marketplace-doc/sPaesDqCRjA9finA/images/use-dify/tutorial/workflow-101-lesson-09/output-node.png?fit=max&auto=format&n=sPaesDqCRjA9finA&q=85&s=252efc710f199123ef6ea7bfae6bcb5d" alt="Point the Output at the Template" width="1804" height="454" data-path="images/use-dify/tutorial/workflow-101-lesson-09/output-node.png" />
    </Frame>
  </Step>
</Steps>

Here's the final workflow.

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-preview-yajing-marketplace-doc/sPaesDqCRjA9finA/images/use-dify/tutorial/workflow-101-lesson-09/final-workflow.png?fit=max&auto=format&n=sPaesDqCRjA9finA&q=85&s=d8fcdc43f0e36ad145d2357fe4700f65" alt="The Final Workflow with the Template Node" width="2912" height="454" data-path="images/use-dify/tutorial/workflow-101-lesson-09/final-workflow.png" />
</Frame>

Click **Test Run**. Ask multiple questions in one email. Notice how your final output has a perfectly written custom intro, the LLM's beautifully summarized answers in the middle, and a standard, professional signature at the bottom.

## Mini Challenge

1. Add a conditional fallback when `customer` is empty, such as `Hi there,`.
2. Add a fixed support disclaimer that the Agent cannot change or omit.
