typebot.io icon indicating copy to clipboard operation
typebot.io copied to clipboard

Add Loop block functionality

Open defsanmith opened this issue 4 months ago • 2 comments

Problem / Motivation TypeBot currently has no native mechanism to repeat a sequence of blocks. Builders are forced to:

  • Duplicate blocks manually
  • Inject custom JavaScript
  • Abandon certain use-cases altogether A first-class Loop Block lets flows iterate over a list or repeat until a condition is met, unlocking multi-item data capture, retry logic, dynamic surveys, and more.

Proposed Solution Add a Loop (Iteration) Block that can wrap any sub-flow and execute it repeatedly based on iterations = n; exits when counter reaches zero

Builder UX

  • Drag-and-drop "Loop" container; creators can next blocks inside.
  • The side panel shows a loop model dropdown and configurable parameters.
  • Visual badge displays current mode, e.g., For-Each.

Runtime behavior

  • Maintains loop index (loop.index, loop.item) in conversation state.
  • Supports a break via a "Break Loop" exit inside nested blocks.
  • Hard guardrail maxIterations to prevent infinite loops.

defsanmith avatar Jun 08 '25 01:06 defsanmith