> ## Documentation Index
> Fetch the complete documentation index at: https://docs.callkaro.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditions

> Branch on a code result, the contact, the message, who replied last, or a count over the chat — all checked by code

A Condition has one or more **rules**, then **Otherwise**. Rules are checked top to bottom, by code; the first that holds wins, and Otherwise takes everything else. Nothing here asks an AI.

## What a rule reads

| Source | Reads | Example |
| - | - | - |
| **A code result** | A field of a Run code step's result, by its key and a path | `classify` · `intent` equals `pricing` |
| **A contact attribute** | One of your contact attributes, or the phone number | `lead_stage` equals `paid` |
| **The message** | Its text, its type, the tapped button's id, or its media link | Tapped button id equals `buy` |
| **Who sent the last reply** | The agent, or the workflow step, that sent the latest reply in the chat | The agent that sent it equals *Sales agent* |
| **A count over the chat** | One of the counters below | Replies from *Sales agent* is greater than `4` |

### Counts over the chat

Counted from the stored chat (since it was last cleared), with no AI. **In the last … hours** narrows the window; `0` counts since the chat began.

| Counter | Counts |
| - | - |
| **Replies from an agent** | Replies one of your agents sent. Pick steps of an Advanced agent's flow to count only the replies from those steps — e.g. its *Answer* steps, to count the questions it has answered |
| **Messages sent by steps** | Messages that chosen steps of this workflow sent — e.g. how often the payment link went out |
| **Messages from the user** | Everything the user sent |
| **Times the user sent this exact text** | Messages with the same text as this one, ignoring case and outer spaces |

The user's current message is already counted: *Times the user sent this exact text* greater than `2` means "this is at least the third time".

## How it compares

| Operator | Holds when |
| - | - |
| **equals**, **does not equal**, **contains** | Text compares ignore case |
| **has any of these words** | The text holds one of the words or phrases you list (comma or one per line) as whole words, in any script: `paid, done, ho gaya, भुगतान` matches "I paid" but not "unpaid" |
| **matches the pattern** | A regular expression, ignoring case: `^(image\|video\|sticker)$` |
| **is greater than**, **is less than** | Numbers — counters, scores, amounts |
| **is empty**, **is not empty** | No value needed |

## Common rules

| You want | Rule |
| - | - |
| A tapped button | The message · Tapped button id · equals · `buy` |
| A photo, video or sticker | The message · Its type · matches the pattern · `^(image\|video\|sticker)$` |
| A voice note | The message · Its type · equals · `audio` (its words are in *Its text* when Audio Transcription is on) |
| A payment claim in words | The message · Its text · has any of these words · `paid, done, payment done, ho gaya` |
| A flood of repeats | Times the user sent this exact text, last 2 hours · is greater than · `2` |
| Keep the user with an agent | Who sent the last reply · The agent that sent it · equals · *your agent* |
| A limit kept on the contact | A contact attribute · `other_messages_count` · is greater than · `5` |

Put the cheap rules first — button ids, keywords, the message type — and code that calls an API after them, so most messages are decided without one.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.