How to create and configure Slots

icon picker
Implementing Loops in a Script | Repeat slot

Purpose and general information

The
@Repeat
@Slot
and its
@Child Slot
s (
@Repeat Next
,
@Repeat End
,
@Repeat Error
,
@Repeat Limit
) are designed to execute a loop of a specified number of iterations in the
@Script
.
The
@Repeat
@Slot
is a
@Complex Slot
and cannot exist without four
@Child Slot
s:
@Repeat Next
,
@Repeat End
,
@Repeat Error
,
@Repeat Limit
, which begin their own
@Script Branch
es.
It is not possible to add other
@Child Slot
s.
image.png
@Limit on the number of iterations of the cycle of one Repeat Slot
: 500 iterations.
Several
@Repeat
constructs are allowed in a
@Script
.
The
@Repeat Next
@Subslot
and the following
@Script Branch
are a loop branch. The script follows this
@Script Branch
until one of the following conditions is met:
the number of loop iterations set in the
@Slot
has been reached;
a message from the
@Bot User
is received, if there is no
@Slot
in the cycle that can process it;
@Limit on the number of iterations of the cycle of one Repeat Slot
(500 iterations) or
@Limit on the number of iterations of the cycle per minute per Company
(200 iterations) has been reached.
The
@Repeat End
@Subslot
is intended for continuing the
@Script
when the cycle has ended, i.e. the number of loop iterations set in the
@Slot
has been completed, as well as to exit the loop if, during its execution, a message from the
@Bot User
was received, and there is no
@Slot
in the loop that can process it.
The
@Repeat Error
@Subslot
is intended to continue the
@Script
if a loop execution error occurred when an invalid number of iterations was set.
The
@Repeat Limit
@Subslot
is designed to exit the loop when the
@Limit on the number of iterations of the cycle of one Repeat Slot
(500 iterations) or the
@Limit on the number of iterations of the cycle per minute per Company
(200 iterations) is reached.

Slot creation and settings

Slot attributes

image.png
Slot Name ー the name of the
@Slot
, which will be displayed in the
@Script Tree
. The maximum length of a field value is 40 characters.
Number of iterations ー Number of loop iterations.
Valid values:
exact value — positive integer or 0;
The
@Expression
that gives the result that is a positive integer or 0;
@Context Variable
.
Trimming spaces: by clicking the CREATE button (when creating a
@Slot
) or SAVE (when editing a
@Slot
), spaces and line breaks at the beginning and end of the Number of iterations field are trimmed.
When importing an
@Agent
configuration file with an invalid value in the Number of iterations field (see paragraph 2a), error messages will be displayed and the
@Agent
will not be imported into the
@Platform
. ​
image.png

Repeat Next, Repeat End, Repeat Error, Repeat Limit slots

image.png
When creating a
@Slot
, four
@Subslot
s are automatically generated:
@Repeat Next
,
@Repeat End
,
@Repeat Error
,
@Repeat Limit
.
These
@Subslot
s cannot be changed and can only be removed from the
@Parent Slot
.
The location of the
@Subslot
s is determined automatically; you cannot move the
@Subslot
s:
The
@Repeat Next
@Subslot
is always the topmost
@Subslot
in a given
@Complex Slot
;
The
@Repeat End
@Subslot
is always the second in order
@Subslot
in a given
@Complex Slot
;
The
@Repeat Error
@Subslot
is always the third in order
@Subslot
in a given
@Complex Slot
;
The
@Repeat Limit
@Subslot
is always the lowest
@Subslot
in a given
@Complex Slot
.
You cannot add new
@Subslot
s to the
@Parent Slot
@Repeat
.

Subslot attributes

Repeat Next

image.png
Slot Nameー the name of the
@Slot
, which will be displayed in the
@Script Tree
. The maximum length of a field value is 40 characters. By default, the field is set to Repeat Next.

Repeat End

image.png
Slot Nameー the name of the
@Slot
, which will be displayed in the
@Script Tree
. The maximum length of a field value is 40 characters. By default, the field is set to Repeat End.

Repeat Error

image.png
Slot Nameー the name of the
@Slot
, which will be displayed in the
@Script Tree
. The maximum length of a field value is 40 characters. By default, the field is set to Repeat Error.

Repeat Limit

image.png
Slot Nameー the name of the
@Slot
, which will be displayed in the
@Script Tree
. The maximum length of a field value is 40 characters. By default, the field is set to Repeat Limit.

Using syntax in Slot

In the
@Repeat
@Slot
, it is allowed to use
@Expression
in the Number of iterations field. More details:

Slot operation

To reflect the number of the current loop iteration, the
@System Context Variables
@repeat_index
are used. The numbering of iterations starts from 0.

Starting a cycle

When entering the
@Repeat
@Slot
, the value of
@repeat_index
is set to -1, and the value of the
@Number of Loop Iterations
is calculated in the Number of iterations field:
If the result of the calculation is not an integer or a number less than 0, a transition to
@Repeat Error
occurs, and:
the value of
@repeat_index
does not change and remains equal to -1 (there was an attempt to start the cycle, but it didn’t work);
@error
takes the value invalid number of iterations.
The cycle state is reset (see )
If the result of the calculation is 0, the transition to
@Repeat End
occurs, and:
the value of
@repeat_index
does not change and remains equal to -1 (they tried to start the cycle, but it never worked)
The cycle state is reset (see )
If the result of the calculation is an integer greater than 0, the transition to
@Repeat Next
occurs.

Continuation of the cycle

The
@Repeat Next
script branch implements a cyclic algorithm without blocking.
You can go to
@Repeat Next
:
from
@Parent Slot
@Repeat
;
using the
@Jump
@Slot
;
automatically from the end of the
@Repeat Next
@Script Branch
— transition to the next iteration of the cycle.
When entering the
@Repeat Next
@Subslot
, it is determined where the next transition needs to be made, then the transition itself is performed:
The achievement of the number of loop iterations specified in the
@Repeat
@Slot
is checked: if the
@repeat_index
value is greater than or equal to the number <value specified in the Number of iterations field> - 1, then the transition to the
@Repeat End
@Script Branch
occurs.
Example: the number 10 is specified in the Number of iterations field. The numbering of iterations in
@repeat_index
starts from 0, then when
@repeat_index
takes the value 9, a transition occurs to the
@Repeat End
@Script Branch
.
The
@Limit on the number of iterations of the cycle of one Repeat Slot
is checked: if the
@repeat_index
value is greater than or equal to the
@Limit on the number of iterations of the cycle of one Repeat Slot
:
A transition to the
@Repeat Limit
@Script Branch
occurs.
The cycle state is reset (see )
Example: The
@Limit on the number of iterations of the cycle of one Repeat Slot
is 500. If the
@repeat_index
value is 500 or 501, a transition to the
@Repeat Limit
@Script Branch
occurs.
Start of the next iteration of the cycle: If the previous operations did not reach the
@Repeat Limit
and
@Repeat End
@Subslot
s, then the
@repeat_index
value is increased by 1 and the transition to
@Repeat Next
occurs.
Example: the Number of iterations field contains the number 10. The value of
@repeat_index
is 3. In this case,
@repeat_index
takes the value 4 and the transition to the
@Repeat Next
@Script Branch
occurs.
An artificial delay of 0.3 seconds was introduced between loop iterations.

Interrupting and ending a loop

The cycle is interrupted and completed:
Due to jumping beyond the
@Repeat Next
@Script Branch
using the
@Jump
@Slot
;
Example: in this
@Script
there is a transition from the
@Repeat Next
@Script Branch
to the
@Text
@Slot
with ID 11762076.
image.png
image.png
Due to the transfer to the operator;
Due to the receipt of a
@Bot user’s Message
, for processing of which there is no
@Slot
in the
@Repeat Next
@Script Branch
;
Due to reaching the
@Limit on the number of iterations of the cycle per minute per Company
;
Due to exceeding the
@Limit on the number of iterations of the cycle of one Repeat Slot
.

Resetting the cycle state

The cycle state is reset when entering the
@Repeat Error
,
@Repeat End
,
@Repeat Limit
@Subslot
s, as well as at the next Initiation of the cycle.
When resetting the cycle state:
the cycle ends;
@repeat_index
remains in the
@Chat Context
, the value of which is the index of the cycle at the last completed iteration;
the loop state becomes uninitiated.
To restart a loop after resetting the loop state, the
@Repeat
@Slot
must be executed in the
@Script
to initiate the loop.

Special execution cases of Script Branch Repeat Next

In case there is a transition to the
@Repeat Next
@Script Branch
using the
@Jump
@Slot
, with the exception of a transition to the
@Repeat Next
@Slot
itself, and
cycle initiated:
The
@Conversation
moves to the end of the
@Script Branch
without incrementing
@repeat_index
, and then moves to the
@Repeat Next
@Script Branch
for the next iteration, according to paragraph 3 of the section.
the cycle is not initiated and/or the value specified in the Number of iterations field is not calculated:
after passing the
@Repeat Next
@Script Branch
to the end, a transition to the
@Repeat Error
@Script Branch
occurs (except for the case when you went beyond its limits using
@Jump
@Slot
)
After resetting the loop state, the next time you move to the
@Repeat Next
@Script Branch
using the
@Jump
@Slot
(without passing the
@Repeat
@Slot
again), after passing the
@Repeat Next
@Script Branch
, a transition will be made to the
@Repeat Error
@Script Branch
(provided that there is no
@Repeat Next
@Script Branch
going beyond it using the
@Jump
@Slot
).
If there is a
@Change Chat Mode
in the
@Repeat Next
@Script Branch
, then the
@Dialog
is closed and the next iterations are not performed.
If the current
@Repeat Next
iteration does not have an
@Input Waiting Slot
, but during the execution of this iteration a
@Bot user’s Message
is received, then after the completion of the current iteration, a transition to the
@Repeat End
@Script Branch
occurs.
If, while performing iterations, the
@Limit on the number of iterations of the cycle per minute per Company
is reached, then a transition to the
@Repeat Limit
@Script Branch
occurs, which can happen before, after or during the iteration.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.