> For the complete documentation index, see [llms.txt](https://docs.aitheon.com/creators-studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aitheon.com/creators-studio/standard-components/sequence.md).

# sequence

## split

This component splits a payload to separate messages.&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWhqnAW2DQOh3rMI6V_%2F-MWhtK5Us4Bkd6TMFYFh%2Fsplit.gif?alt=media\&token=b358b2b4-c42b-4725-903b-3db931d38a45)

In this example, we create three types of input and the **split** component separates each **msg.payload** to messages.&#x20;

#### Properties&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWhvKk0g3kQ2LJpT3aV%2F-MWi2I60jAhNqQsWrAXj%2Fsplit%20prop.png?alt=media\&token=9dfdf85d-5047-4a7c-9362-eeb68bdeb968)

You may set up properties for all types of payload, the component will use them according to the input.

**String/Buffer**

**Split using (1)** - choose the type the splitter: **string** (default "\n"), **buffer**, or **Fixed** **length of** (will split on messages of specified length).

**Handle as a stream of messages (2)** - in this mode, the component will hold the last incomplete part of the message (in our instance **str3** has no the **/** splitter) and add it in front of the first part of the next one. So all the incoming messages are considered as one stream and split when the divider comes, and, for example, three msg.payloads '**Hello,** ',  '**world!**', and '**/**' will be merged to **Hello, world!** with the **split** component (if **Split using** the **/** splitter)!

**Array**

**Split using (3)** - specify the fixed number of arrays elements of each output payload.&#x20;

But if the last part of the array has fewer elements than this number, it still will be sent. For example, the split component with **Fixed length of 2** will split the array \[1, 2, 3] to \[1, 2] and \[3].

**Object**

**Copy key to (4)** - when splitting an object the component returns only values of its properties in msg.payloads. You can specify an **msg** property to show the keys of values. (These keys are also sent in the **parts** property object - see below).

{% hint style="info" %}
Note: the component also adds **parts** property with details of splitting to the output message (see the component's **Help**). This property is used by the **join** component to merge messages. (See below).
{% endhint %}

## join

The opposite to the previous component. It merges messages into one payload. There are three modes of component's properties.

#### Properties

1. **automated** mode &#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWj0yd63ScR4aa7pf1d%2F-MWj6NQdAZVjtA1qIu5v%2Fjoin%20split.gif?alt=media\&token=76a5b268-be40-42e2-af13-afb1d7a43add)

In this mode, the component joins inputs using the **msg.parts** property that is made by the split component. For the instance, we took the split flow and checked if there the parts property. Then we checked the merged message of the join component.&#x20;

**2. manual**&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWjC2Kb85v-s7zXSSl4%2F-MWjCzv5imtwV1RLS6zj%2Fjoin%20manual%20prop.png?alt=media\&token=cd9c8afa-69aa-4f79-b04e-160fbd2d1878)

**Combine each (1)** - specify the msg property for the merger (**msg.payload** by default).

**to create (2)** - choose the resulting payload type: **a String**, **a Buffer**, **an Array**, **a key/value Object**, or **a merged Object**.&#x20;

If you choose **a key/value Object** you will be prompted to specify the msg property which value will be used as the key. By default, it's **msg.topic** so the resulting object will have values of **msg.topic: msg.payload**.&#x20;

**joined using (3)** - specify the joining characters. By default, it's **\n** (it will not be reflected in the message, but this notion means that each part of the message will be in a new line). If the field is empty, the messages will be merged without any dividers: '**Hello**' and '**world**' will be combined to '**Helloworld**'.&#x20;

**Send the message:**

* **After a number of message parts (4)** - if you put **2** in the field, every two messages will be merged and sent. And so on.
* **After a timeout following the first message (5)** - specify in seconds how often the merged message will be sent. All the messages that arrived in each time span will be combined. It has to be at least one message to make an output.
* **After a message with the msg.complete property set (6)** - not an option. A message with this property will trigger the **join** component output (even if it is not completed due to other settings).&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWjM3UyofRkebVHKocH%2F-MWjNa8FPrBfNQQdo07M%2Fjoin%20manual.gif?alt=media\&token=8a934e21-2d2b-461d-bdb8-95d374cc0332)

**3. reduce sequence**

For this mode, the incoming messages must have the **msg.parts** property (for example, made by the **split** component) - that means the output message will be sent only when all parts have arrived (in our example, the split component divided the message to three parts).   &#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWwnBNBuXLQb10_p6uA%2F-MWx6LoC67QHhfnn89Lu%2Freduce%20props.png?alt=media\&token=d4019e48-f08c-4d50-9816-b3a2763dc79d)

**Reduce exp (1)** - a [JSONata](https://jsonata.org/) expression that is executed with each incoming message. The result is passed to the next call of the expression as the accumulated value (read the **join** component **Help**). Click three dots to open the JSONata expression editor and select wanted functions. In the Test tap of this editor, you will be able to test the expression result.&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWx6X_dGLe_MSMK-s_6%2F-MWxpUBxjjFSeElXS7IA%2Fjsonata.png?alt=media\&token=39340848-17f5-4199-88f3-b107a2eb339e)

**Initial value (2)** - set up the initial value ($A in JSONata expressions)

**Fix-up exp (3)** - the expression that will be called on the result of **Reduce exp** call on each message.

Learn more about JSONata expression in the component **Help**.

## **sort**

This component sorts incoming message elements or messages sequence using a specified key.&#x20;

For example, you can put in order the messages from various sensors. Or create a new sorted array message from an array of raw data.

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWy-B873oIXnfHIPzI5%2F-MWy0abs-u6MqQ2sWWRs%2Fsort.gif?alt=media\&token=e1cea535-02be-4082-b14d-a7998ea19abf)

In this example, we first check the split component output: three strings of the initial array. Then we sort these messages sequence as strings and then as numbers (but the output messages are still strings).

#### Properties&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWy2c3u8y8YR9PdwlOQ%2F-MWy2ymx2wy_HEcoWAzT%2Fsort%20props.png?alt=media\&token=37166d11-3a88-481a-9771-f6d19fe4de85)

**Sort (1)** - choose what to sort: a message property (**msg.payload** by default) or a sequence of messages.

**Key (2)** - choose the key for sorting.&#x20;

For a message property, the key may be an **element value** or JSONata expression. For example, the array `[154,3,12]` will give the `[3,12,154]` output array (in ascending order).

For a **message sequence**, the key may be a message property (for example, msg.payload as in our instance) or JSONata expression.&#x20;

{% hint style="info" %}
The component requires the **msg.parts** property to determine the bunch of messages to sort (this property is created automatically by the **split** component, or you can specify it manually - see the property object structure in the component **Help**). &#x20;
{% endhint %}

**Order (3)** - you can sort in ascending or descending order.

**(4)** - also the component can consider the data as numbers (if possible). In our example, we sorted string messages as numbers.

## batch

The component creates sequences of messages in three modes. The component collects messages while 'waits' a specified condition, and then sends a batch of outputs at a time.

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWy6UV75x7gn3jQKQ5a%2F-MWyJns-iXzGoWEpkHyJ%2Fbatch.gif?alt=media\&token=1a66d51c-1db5-4890-803b-5541fcd06783)

#### Properties

**Group by number of messages** mode **(1)**&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWyJtDcGeUvY5Vg9fnw%2F-MWyKZzl8ticbEcSHJTV%2Fbatch%20props.png?alt=media\&token=e6949d71-8fbe-49bc-8453-84ba7885fb7c)

Specify the **Number of messages** to make a batch **(2)**.&#x20;

Select **Overlap (3)**. You can order the component to use the defined number of last elements of one batch to be used as the first elements of the next batch.

**Group by time interval** mode &#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWyJtDcGeUvY5Vg9fnw%2F-MWyMbP6vEdf50D_J29N%2Fbatch%20by%20time.png?alt=media\&token=153f3a63-778e-41f9-b6bd-074dbe1897b4)

Choose the interval for sending sequences of messages. The component can send an empty message if there is no incoming data during the interval.

**Concatenate messages** mode&#x20;

![](https://3983587133-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvAp4NFmv7Cj5kJvKjw%2F-MWyJtDcGeUvY5Vg9fnw%2F-MWyNEhsd6jRaAfB0pA0%2Fconcat%20batch.png?alt=media\&token=2d5f1f47-8c20-422f-87f9-22f5301e83b8)

Add the **msg.topic** properties of incoming messages to make a sequence.&#x20;

{% hint style="info" %}
Note: each incoming message must have **msg.parts** property to identify its sequence.
{% endhint %}
