Flow Logic
In NappAI, flow logic combines classic automation structures with reasoning driven by AI through intelligent agents and chains of thought.
Every flow not only executes predefined steps but also thinks, decides, and adapts its behavior based on the context and data it receives.
Conditional Reasoning (Equivalent to “IF”)
In NappAI, conditional logic (“if this happens, do that”) can be approached in two main ways: one based on fixed rules and one driven by artificial intelligence.
1. Fixed Rule-Based Conditional (The Switch Component)
For clear, predefined rule logic, the Switch component is used. This is the direct equivalent of a traditional “IF” statement.
- Functioning: The
Switchcomponent evaluates an input data and, based on conditions you define (e.g.,if value is > 10orif text contains "urgent"), directs the flow through one of several outputs that you have configured.
2. Intent-Based Routing (Agent + Switch)
For more advanced and flexible logic, you can combine the intelligence of an Agent with the structure of a Switch. In this pattern, the Agent is not the one routing, but the one deciding where to route.
- Functioning:
- An Agent is configured to act as a “classifier.” Its sole task is to analyze the input (e.g., a customer email) and return a single word or category (e.g., “Support”, “Sales”, “Urgent”).
- The text output of this Agent is connected to the input of a
Switchcomponent. - The
Switchthen uses that word to direct the flow to the correct branch (e.g., the “Urgent Support” branch), executing the logic in a simple and orderly manner.
This approach combines the power of AI to understand the meaning with the robust structure of the Switch to control the flow.
Intelligent Iterations (Equivalent to “Loop”)
The concept of a loop in NappAI works similarly to traditional automation, allowing you to process each element of a list. A loop component will receive a list as input and execute a series of actions for each element of that list.
DoneOutput: A key feature is that the loop component must have aDoneoutput (or similar). This output is activated once all items in the list have been processed, allowing the rest of the flow to continue in an orderly fashion after the loop has finished its work.
Data Merging and Synthesis (Equivalent to “Merge”)
In NappAI, combining data from different branches of a flow can be done in two main ways: through manual merging components or through intelligent Agent synthesis.
Manual Merging with Components
For total and explicit control over how data is combined, you can use a variety of components designed for this task:
PromptorParse Data: These components are excellent for merging text. You can use their templates to take variables from different inputs and combine them into a single text string with the exact formatting you need.Merge Data: This component is specifically designed to merge data objects (JSON). You can configure how the fields from two or more inputs are combined into a single output object.Combine Text: Similar toParse Data, this component is optimized for joining multiple text strings, often with a defined separator.
This method is ideal when you know exactly how you want the data to be joined and complex reasoning is not required.
Cognitive Synthesis with Agents
When you need the merging to be more than a simple union of data, an Agent performs a cognitive synthesis. It receives information from multiple tools and, instead of just joining it, it understands it, reasons about it, and reformulates it into a single, coherent, and contextualized response.
- Practical Example: Imagine you ask an agent: “Give me a summary of the company NappAI and search for its most recent news.”
- The Agent receives the request.
- It invokes the
Web Scrapertool to extract the description from NappAI’s “About Us” page. - In parallel, it invokes the
Google Searchtool with the query “news about NappAI” to get recent headlines. - Synthesis: The Agent receives both data groups (the company description and the list of news) and, instead of showing you the raw data, it generates a unified and fluid response.
Sub-flows as Tools
Modularity and logic reuse are achieved by converting entire Projects into tools. In NappAI, this is accomplished using the Sub Project Flow component.
- Functioning: By adding the
Sub Project Flowcomponent to your canvas, you can select a Project that you have already saved. This component converts that entire Project into a single Tool that can be used by an Agent in another flow.
The Agent does not need to know the internal details of the sub-project; it simply invokes it as a “black box” to perform a complex task, making your main Projects cleaner and more organized.
Adaptive Flow (Equivalent to “Execution Order”)
In traditional flows, the order of execution is rigid and defined by the connections. With a NappAI Agent, the workflow is adaptable. The Agent creates a dynamic execution plan based on the user’s request. It may decide to call Tool A and then C, or start with B, depending on what is most logical to solve the problem.
Files (Binary and Base64)
Working with files is a key capability in NappAI. It is fundamental to understand how file data is handled within the platform.
The Role of Tools
An Agent does not handle files directly but uses Tools to interact with them. For example, you can connect a component like Google Drive File Manager as a tool to your agent.
- The Process:
- The Agent receives an instruction like “summarize the document ‘annual-report.pdf’ that is in my Drive.”
- The Agent calls the
Google Drive File Managertool with the file name.
Handling Formats: Base64 and Binary
This is where an important technical step occurs:
- Download in Base64: When a component like
Google Drive File Managerdownloads a file, it converts it to Base64 format. Base64 is a way to encode binary data into plain text, which facilitates its transmission through APIs and within the NappAI flow. - Binary Processing: The Base64 text is sent to the next component in the flow (e.g., a
Parse Dataor aLoader). This receiving component is designed to automatically decode the Base64 and process the content as binary data to extract the relevant text or information.
In summary, although files are transmitted as Base64 between components, the file processing components are built to understand and work with the original binary content. As a user, you generally don’t need to worry about this conversion, but it’s useful to know for debugging issues or building custom flows.