Skip to content

Flow logic

A simple flow runs in a straight line: it receives something, processes it and returns a result. Many automations need more: choose a path depending on the data, repeat some steps for each item in a list or make use of a flow you already have. This page explains how to do each of these in NappAI.

Almost everything can be done in two ways:

  • With fixed rules, when you know exactly which condition to check: “if the status is paid, do this”.
  • With an agent, when the decision depends on meaning: “if the customer is upset, hand them over to a person”.

Choose a path

With fixed rules

ComponentWhen to use it
SwitchSplit records across several paths depending on the value of one of their fields. You define several cases, each with its own condition (equals, contains, is empty…), and each case has its own output.
Conditional RouterCompare one text with another and continue through True Route if the condition is met or through False Route if not.
Data Conditional RouterSeparate records depending on a condition on one of their fields.

Example: orders with the status paid go to invoicing and the pending ones get a reminder.

With an agent

When the condition can’t be written as a rule, let an agent classify first and then use a fixed rule on its answer:

  1. An Agent reads the message and, following its System Prompt, answers with a single category only, for example Support, Sales or Urgent.
  2. A Switch or a Conditional Router looks at that word and sends the flow down the matching path.

This way the AI takes care of understanding the message and the rest of the flow follows a clear path that is easy to review.

Let the agent decide what to do

If you connect several tools to an agent, you don’t need to draw each path: the agent decides in each conversation which tools to use and in what order. For example, given “am I free on Thursday? If so, let Marta know”, it can check the calendar and then send the message.

See Tools.

Repeat steps for each item in a list

A step often returns a list: unread emails, the rows of a spreadsheet, today’s orders. There are two ways to handle each item:

WayHow it worksWhen to use it
Batch ModeTurned on in the settings of the component that receives the list. The component processes all the items and returns a list with all the results.When each item is handled separately by a single component, for example summarising each email.
Loop and Loop EndLoop hands the items one at a time to the steps you connect, and Loop End marks the end of those steps so it moves on to the next one.When several steps must be repeated in order for each item, for example writing and sending an email to each contact.

See Process lists.

Combine information

When information comes from several steps and has to be put together:

ComponentWhat for
PromptWrite a text with slots in braces, such as {customer} or {order}, that are filled with what comes from other components. It is the usual way to prepare what is passed to a model.
Parse DataTurn records into readable text following a template.
Combine TextJoin two texts with a separator.
Merge DataPut records from several sources in a single list, one after another or matched on a common field.

An agent can also combine information: if it consults two tools, it doesn’t give you both results separately but a single answer written with both.

Reuse a flow inside another

If you have a flow that does a task well, you can use it inside others instead of repeating it:

ComponentHow it is used
Sub Project flowInserts another flow as one more step: it passes in the input data and returns its result.
Project flow as ToolTurns another flow into a tool that an agent can use when it needs it.

Your main flows stay shorter and each task is kept in one place.

When something fails

If a component fails during a run, it is marked on the canvas with a red triangle and the reason is recorded in the execution. To find it:

  1. In the playground, look at Executions to see what each step received and returned.
  2. Outside the editor, find the execution in Executions Logs and open it to see the details.

See What each component shows and Execution logs.