← All nodes
Decisions word_counter

Word Counter

Accumulates words across turns and fires a branch once a threshold is reached.

What does it do?

Counts how many words a text has.

How does it work?

Receives text and applies a simple formula to return the total word count.

Why use it?

Useful as a basic example of custom node creation or to limit response size before sending via SMS.

Inputs

nametype
text string

Outputs

nametype
words_in_turn number
total number
threshold number
reached boolean
branch string

Branches

Fixed branches

  • reached — Reached
  • below — Below

Configuration

memory_key string required default: "words_accumulated"
threshold integer required
text_field string required default: "text"
reset_on_fire boolean required default: true
branch_when_reached string required default: "reached"
branch_when_below string required default: "below"
accumulate_text_memory_key string optional
output_field string required default: "accumulated_text"

Default configuration

{
  "memory_key": "words_accumulated",
  "threshold": 20,
  "text_field": "text",
  "reset_on_fire": true,
  "branch_when_reached": "reached",
  "branch_when_below": "below",
  "output_field": "accumulated_text"
}

Emitted events

  • counter.updated

    Word counter updated after a turn.