Loop

LoopLogic

Run the nested blocks a fixed number of times.

  • Loop block: the blocks placed inside it run once for each item, and can use the current item's outputs.

Inputs

IterationsRequired

Number of times to run the loop body.

Example: 3

Loop Body

Blocks to run each iteration.

Holds blocks

Outputs

Current Iteration

1-based index of the current loop run.

Example: 1

Total Iterations

Total number of times this loop will run.

Example: 5

Build a bot using blocks like Loop

Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.

Advanced Documentation

This documentation can be useful when using code mode. View as Markdown

ID: loop_basic
  • Loop block: write for item := range loop_basic(Args{...}) { ... } and read the current item's outputs from item. See loops.

Inputs

FieldInventScript nameValue
Iterationsiterationse.g. "3"
Loop Bodybodyblocks: func() { ... }

Outputs

FieldInventScript nameValue
Current Iterationcurrent_iteratione.g. "1"
Total Iterationstotal_iterationse.g. "5"

Example InventScript

for range loop_basic(Args{iterations: 3}) {
	send_text_message(Args{channel_id: trigger.channel_id, message_content: "Next item"})
}

More logic blocks