This article provides a comprehensive guide to using the Template Node within the AgentRunner platform. The Template Node is a powerful tool that enables you to dynamically generate text by merging and inserting various inputs into a predefined template. Whether you need to combine multiple data points, insert information into a structured sentence, or create complex text structures, the Template Node offers the flexibility and control you need. This guide is designed for AgentRunner users of all levels, from beginners to advanced users, who want to leverage the full potential of dynamic text generation in their agents.
Harnessing the Power of the Template Node
The Template Node is an "Advanced text merger" within AgentRunner, designed to provide unparalleled flexibility in text manipulation. Unlike the standard Text Merger node, which is limited to concatenating two text strings, the Template Node can handle an unlimited number of inputs, allowing for intricate text compositions. This advanced capability enables you to:
Key Capabilities and Benefits
Merge Multiple Inputs: Combine numerous variables seamlessly into a single text output.
Integrate Inputs with Fixed Text: Incorporate one or more inputs into a static text block.
Insert Inputs Dynamically: Place inputs anywhere within a fixed text, providing precise control over the final output.
Reuse Inputs: Use the same input multiple times within the text, enhancing flexibility and reducing redundancy.
Real-World Applications
Dynamic Reporting: Generate customized reports by merging real-time data with pre-defined templates.
Personalized Messaging: Create personalized email or SMS messages by inserting user-specific information into message templates.
Code Generation: Generate code snippets by combining variable inputs with fixed code structures.
Structured Data Creation: Construct structured data formats like JSON or XML by merging inputs into the appropriate syntax.
Step-by-Step Guide to Using the Template Node
The Template Node is a versatile tool in AgentRunner, allowing you to merge and insert unlimited variables into a text template. Follow these steps to effectively use the Template Node in your agent workflows:
Add the Template Node: Drag and drop the Template Node onto your agent's node editor.
Connect Inputs: Connect the desired input nodes to the Template Node. The Template Node supports an unlimited number of inputs.
Define Your Template: Open the Template Node editor and enter your text template. Use the syntax {{variableName}} to specify where you want to insert the values from your input nodes. You can name your variables in any way, as long as they are surrounded by {{ and }}. For example, {{firstName}}, {{lastName}}, {{city}}.
Visual Aid: Consider adding a screenshot showing the Template Node editor with a sample template.
Format Your Output (Optional): Utilize Markdown to format the output text (e.g., bold, italics, lists, tables).
Tip: Markdown formatting allows you to create well-structured and visually appealing text outputs.
Test Your Template: Click on the "History" tab within the Template Node editor to preview the merged text. This allows you to verify that the inputs are correctly inserted and formatted.
Note: Testing is crucial to ensure that your template works as expected, especially when using complex templates or multiple inputs.
Connect to Output: Connect the Template Node to the next node in your workflow, such as a Text Output node or another processing node.
Run Your Agent: Execute your agent to see the final merged text output.
Expected Outcome: The output should display the merged text with all variables correctly inserted into the template, formatted according to your Markdown specifications.
Handling Empty Inputs and Conditional Logic
Handling Empty Inputs: Ensure that all input nodes provide a value. The Template Node will return an error if any input is empty.
Warning: Always validate your inputs to prevent errors during agent execution.
Implementing Conditional Logic: To insert different text based on the value of an input, connect the Template Node to a Condition node. The Condition node will determine which text is inserted based on the specified conditions.
Visual Aid: A diagram illustrating the connection between the Template Node and a Condition node would be beneficial.
Conclusion
By following these steps and utilizing Markdown for formatting, you can create dynamic and well-structured text outputs using the Template Node in AgentRunner.