How do I set up the Edit List step?

Filter, sort, de-duplicate and shorten a list from a tool, an action or a multiple choice.

What is it for?

“Edit List” edits a list and writes the result to a new variable. The list usually comes from a Tool Call's or Integration Action's answer; a multiple-choice answer is a list too.

Visitors don't see this step and the avatar doesn't say anything; the agent carries on without waiting for the visitor.

To add it, click “Add step” on the “Flow” tab, then click “Edit List” in the “Logic” category; the step is added in the middle of the canvas. Its settings are on the “Content” tab of the step panel that opens on the right when you click the step.

This step has no “On-screen text”; instead there's a “Step note” at the bottom of the panel. The note is just for you: visitors don't see it, and it isn't spoken or translated.

In values you use variables from earlier steps, like {city}. For a field inside an answer, add the field's name after a dot: {order.status}. The “Insert variable” button in the boxes lists the variables you can use at that point. A variable that hasn't been filled yet counts as empty text.

Setting up the step

  1. In “List”, write the path to the list itself, like {answer.items}; the whole answer isn't a list. If the list is in a Tool Call's answer, click “Fetch sample data” to call the tool once: you pick one of the “Lists in the answer” and see the “Fields of the first row”.
  2. Turn on the operations you want (see below).
  3. Enter the “Variable name” the result is written to. {list} gives the whole list, {list.1.field} a field of the first item.

Operations

The operations always run in this order, so results like “the 5 cheapest” come out right:

  • “Filter”: only items that meet the rules stay. The rules work as in the Condition step; write the item's field as {item.field} ({item} if the item is a plain value). With no rules, nothing is filtered.
  • “Sort”: type the field to sort by in the box that opens (e.g. price) and choose “Ascending” or “Descending”. Numbers sort as numbers, dates as dates and anything else alphabetically; items with an empty value go last.
  • “Remove duplicates”: type the field to compare in the box that opens; of items with the same value, only the first stays. Since this runs after sorting, the top one stays. With no field, the whole item is compared.
  • “Keep the first N items”: only as many items as the number you enter stay, from the top of the list.

Using the result

You can use the result in later steps: show it as options in a Selection step with “Option source” › “From a variable”, run the same steps for each of its items with a Loop step, or count or add it up with Set Variables' “List summary”. If the result is very long (about 16,000 characters), items are dropped from the end.

Example

A Tool Call writes the available appointment times to {answer}. In Edit List: “List” {answer.slots}; “Filter” {item.seats} · “Number” · “is greater than” · 0; “Sort” by the start field, “Ascending”; “Keep the first N items” 5; “Variable name” next_slots. A Selection step with the “From a variable” source then offers the five earliest times as options.

Things to watch out for

The editor warns you when: no list is chosen, the variable name is invalid, or a filter rule doesn't look at the item's field (such a rule gives the same result for every item). If the path you wrote doesn't point to a list, the sample data shows “This path doesn't point to a list; the result stays empty.” For the Tool Call step, see Integration Action and Tool Call steps.

Variable names can only use the letters a–z, digits and underscores (_); accented letters and spaces drop out as you type. “system” is reserved for system variables, so pick another name.

Problems don't stop you saving: the agent is saved, but the incomplete step won't work as expected in the conversation. Fix the flagged steps, then try the agent with “Preview”. To find flagged steps, see the flow editor.

Related articles

Was this article helpful?

Agenola and our partners use cookies to improve the site and show you relevant ads. We count which of our ads bring visitors without using your name or email; anything more only happens if you allow it. Privacy Policy(opens in a new tab)