Element Generator

Create a series of elements from a collection, such as an array.

When to use?

If you have some sort of a collection of, for example, textual greetings, and you want to use them in something like the Element Queue, or maybe Element Randomizer.

Using the Element Generator, you don't have to manually specify each and every element you want queued or randomized, and instead you can define a collection and what to do with every item in that collection.

How to use

Inside an Element Queue or Element Randomizer, place this inside the main flow. Then, specify which collection of items you want to iterate over, and then place an element inside the Element container of this element.

For every item in the collection you've specified, the Element Generator will read whichever element you have given it, while making certain data available inside its child element's context. Refer to the table below for more information on that.

Example usage

  1. Create a collection of greetings. Store it as either a global service variable, or with the Set Param element. It should look something like this: ${["Hello", "Hi", "Howdy"]}
  2. Place an Element Queue in your service.
  3. Place an Element Generator inside the Element Queue's main flow.
    • For the Items property, use the expression syntax to get your collection of greetings. For example, ${GREETINGS}
    • Under Data collection item name, write greeting
  4. Place a Text Response under the Element flow for the Element Generator.
    • For the Text property, write ${greeting.natural}: ${greeting.value}!
  5. Run your service through the test view. For every greeting you've defined, the Element Generator will take its child, and run it. With this, you no longer have to manually define every entry for your Element Queues and Element Randomizers, and can instead work with collections.

Status variable fields

Fields for property Data collection item name
Field Description
value The actual value of the current element of the collection being iterated over.
index Programmatic index of the current element, beginning with 0.
natural Index of the current element incremented by one, how humans count.
first Boolean value, true if the element is the first in the collection. False otherwise.