Files
dify-docs/en/use-dify/tutorials/workflow-101/lesson-09.mdx
Riskey df19776bb0 Add workflow 101 tutorial (#705)
* add the zh and en workflow 101 tutorials

* refine the formats for readability

* refine formatting and minor issues

* Update Workflow 101 lessons and images

* Update image display in Workflow 101 lesson 01

* Rename Dify workflow image

* Update Workflow 101 Lesson 3 with new images and prompt example

* Update Workflow 101 Lesson 03 images

* Update Dify workflow lesson 4 prompt image

* Update Workflow 101 Lesson 5 with new images and content

* Update Workflow 101 Lesson 6 content and images

* Update Workflow 101 Lesson 08 and add new images

* Refine email reply instruction in Workflow 101 lesson 8

* Update Workflow 101 Lesson 9 with new steps and images

* Update Workflow 101 Lesson 09 content and images

* Fix whitespace in Workflow 101 Lesson 9

* Add image alt text to workflow example in zh lesson 01

* Update LLM node images and text formatting in Workflow 101 Lesson 03

* Update zh/use-dify/tutorials/workflow-101/lesson-05.mdx content

* Update zh/workflow-101/lesson-03.mdx for clarity

* Remove unnecessary italics in Workflow 101 lesson 4

* Update Workflow 101 Lesson 5 for clarity and image display

* Update images in Workflow 101 Lesson 06

* Update Lesson 7 workflow tutorial with new images and text fixes

* Update zh/use-dify/tutorials/workflow-101/lesson-06.mdx content

* Update prompt instructions in Workflow 101 Lesson 06

* Clarify condition in Workflow 101 Lesson 07

* Fix formatting in Workflow 101 lesson 8

* Update Workflow 101 Lesson 9 for email formatting optimization

* Fix typo in Workflow 101 Lesson 9

* Remove Jinja2 example from workflow lesson

* Update image syntax in Workflow 101 Lesson 02

* Update image tag in Workflow 101 Lesson 3

* Remove italics from workflow 101 lessons

* Fix typo in zh/use-dify/tutorials/workflow-101/lesson-05.mdx

* Refine parameter types explanation in Workflow 101 lesson 6

* Refine Chinese text in Workflow 101 lesson 06

* Update Lesson 7: Enhance Workflows content

* Fix formatting in Workflow 101 Lesson 7

* Refine Chinese text in Workflow 101 lesson 8

* Refine instructions for Workflow 101 Lesson 08 test run

* Clarify the purpose of template conversion in Workflow 101 lesson 9

* Update Workflow 101 Lesson 10 image syntax

* Polish workflow 101 tutorials (en/zh) and add ja translation

* Update Workflow 101 lesson 1 content

* Fix formatting and update workflow creation instructions in Lesson 02

* Clarify multi-modal model description in Workflow 101 lesson 3

* Remove italics from workflow tutorial lessons

* Update Workflow 101 Lesson 6 prompt example

* Update formatting in Workflow 101 lesson 8

* Update Workflow 101 lesson 1 content

* Update zh/use-dify/tutorials/workflow-101/lesson-02.mdx content

* Refine Chinese text in Workflow 101 Lesson 3

* Refine RAG explanation in Workflow 101 Lesson 04

* Update zh/use-dify/tutorials/workflow-101/lesson-05.mdx content

* Update formatting in Workflow 101 Lesson 08

* final checks

* format and terminology fixes

---------

Co-authored-by: Anne <annezj92@gmail.com>
2026-03-11 15:42:44 +08:00

94 lines
3.7 KiB
Plaintext

---
title: "Lesson 9: Layout Designer (Template)"
sidebarTitle: "Lesson 9: Layout Designer"
---
In Lesson 8, we successfully built a powerful Agent that can think and search. However, you might have noticed a tiny issue: even though we asked the final LLM to list the answers, sometimes the formatting can be a bit messy or inconsistent (e.g., mixing bullet points with paragraphs).
To fix this, we need a dedicated format assistant to organize the answers into a beautiful, standardized format before the final LLM writes the email.
## 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="Update the LLM Node">
Since the Template node will be handling the greetings, we need to tell LLM to focus solely on the questions and answers. Copy and paste the prompt below or feel free to edit it.
```plaintext wrap
Combine all answers for the original email. Write a complete, clear, and friendly reply that only includes the summarized answers.
IMPORTANT: Focus SOLELY on the answers. Do NOT include greetings (like "Hi Name"), do
NOT write intro paragraphs (like "Thank you for reaching out"), and do NOT include
signatures.
```
</Step>
<Step title="Add User Message">
List the different variables respectively.
<Frame>
![Edit LLM Node](/images/difyworkflow101-lesson09-editllmnode.png)
</Frame>
</Step>
<Step title="Add Template Node">
After LLM node, click to add Template node.
<Frame>
![Add Template Node](/images/difyworkflow101-lesson09-addtemplatenode.png)
</Frame>
</Step>
<Step title="Set up the Input Variables">
Click the Template node, go to the Input Variables section, and add these two items:
- `customer`: Choose `User Input / {x} customer_name String`
- `body`: Choose `LLM / {x} text String`
<Frame>
![Template Input Variable](/images/difyworkflow101-lesson09-templateinputvariable.png)
</Frame>
</Step>
<Step title="Format 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:
```jinja
Hi {{ customer }},
Thank you for reaching out to us, and we are more than happy to provide you with the information you are seeking.
Here are the details regarding your specific questions:
{{ body }}
---
Thank you for reaching out to us!
Best regards,
Anne
```
</Step>
</Steps>
Here's the final workflow.
<Frame>
![Final Workflow](/images/difyworkflow101-lesson09-thefinalworkflow.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. How would you change the Jinja2 code to make a numbered list (1. Answer, 2. Answer) instead of bullet points?
<Tip>
Check the [Template Designer Documentation](https://jinja.palletsprojects.com/en/stable/templates/) or ask an LLM about it.
</Tip>
2. What else can Template node do?