Template
Template lets you dynamically format and combine variables from previous nodes into a single text-based output using Jinja2, a powerful templating syntax for Python. It's useful for combining data from multiple sources into a specific structure required by subsequent nodes. The simple example below shows how to assemble an article by piecing together various previous outputs:
![](https://docs.dify.ai/~gitbook/image?url=https%3A%2F%2F3866086014-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FRncMhlfeYTrpujwzDIqw%252Fuploads%252Fgit-blob-82b1175674b3f5bfcaf4a4b0717e35ee05e4fe51%252Fimage%2520%28158%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=b1fdabc1&sv=1)
Beyond naive use cases, you can create more complex templates as per Jinja's documentation for a variety of tasks. Here's one template that structures retrieved chunks and their relevant metadata from a knowledge retrieval node into a formatted markdown:
![](https://docs.dify.ai/~gitbook/image?url=https%3A%2F%2F3866086014-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FRncMhlfeYTrpujwzDIqw%252Fuploads%252Fgit-blob-b744beee2aca0f019df477641aa58f8e0d85a44e%252Fimage%2520%28159%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=4e3b16de&sv=1)
This template node can then be used within a Chatflow to return intermediate outputs to the end user, before a LLM response is initiated.
The
Answer
node in a Chatflow is non-terminal. It can be inserted anywhere to output responses at multiple points within the flow.
Last updated