> For the complete documentation index, see [llms.txt](https://docs.rooks.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rooks.ai/build-with-your-ai/conditional-logic-and-calculations.md). Agents can also search and read this documentation through its [MCP server](https://docs.rooks.ai/~gitbook/mcp).

# Conditional logic and calculations

Ask your AI to tailor the form using answers and other available information.

Describe the rule to your AI in plain language. Specify what should appear, what it depends on, and what should happen otherwise.

## Show relevant questions and pages

Conditions can control a whole page, an individual question, supporting content, or an answer choice.

> Show the Insurance page only when the person says they have insurance.

> Show “Please specify” only when the person chooses Other.

A condition that reads an answer must use one collected earlier in the form. If the rule needs a later answer, ask your AI to reorder the questions.

## Combine conditions

> Ask for a guardian's contact details when the person is under 18 and has not already provided them.

Tell the AI whether every condition must match or whether any one condition is enough.

## Calculate values

Ask the AI to derive a value from answers.

> Calculate the total number of tickets from the adult and child ticket quantities.

Specify the intended result and test representative cases, including empty or optional answers.

## Use information from outside the questions

Rooks supports variables supplied through URL parameters and values fetched from an API.

> Read a campaign code from the form link and include it in the submitted data.

For an API lookup, provide the endpoint, required inputs, and how to use the result. Keep credentials out of public form content and ask your administrator about the appropriate configuration.

## Test each path

Use the draft preview to test answers that show conditional content and answers that hide it. Check calculations and completion behavior.

The preview's navigation and debug controls can help you inspect pages and current values. Complete the form normally as well to test validation.

Preview does not save responses or test delivery to destinations.
