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

# If-Else

> Let your WordApp make decisions

## What does it do?

If-else nodes, as the name suggests, allow you to create conditional logic in your WordApp. This means you can make your
WordApp do different things based on the content it's generated so far, or the inputs it's received.

If-else nodes give WordApps the ability to make decisions, and sit at the heart of the intelligence AI provides. With Wordware,
you can trivially pass data back and forth between software and AI, leveraging whichever form of intelligence is best for each point
of your workflow.

<img src="https://mintcdn.com/wordware/GaAvACBL43qOk0NE/images/ifelse/if_else_first.png?fit=max&auto=format&n=GaAvACBL43qOk0NE&q=85&s=dea23a85db48f4fd4a8cb18b7e1e9be1" alt="If Else First Pn" width="2344" height="1408" data-path="images/ifelse/if_else_first.png" />

<Note>
  Did you know that WordApps are [Turing
  complete](https://en.wikipedia.org/wiki/Turing_completeness)? The combination
  of if-else nodes and [loop](/nodes/loop) nodes make WordApps capable of
  carrying out any computation a computer can!
</Note>

## How do I use it?

An if-else node is made up of a series of conditions, each with a corresponding action. When the node runs, it checks each condition in turn,
running the nodes inside the first section where the condition is true.

To create an if-else node, type `/if` in the editor, and hit `Enter`. You'll be prompted to fill in some details about the node, like its name, and the conditions and actions you want to include in the attributes editor.

<Frame>
  <img src="https://mintcdn.com/wordware/GaAvACBL43qOk0NE/images/ifelse/if_else_second.png?fit=max&auto=format&n=GaAvACBL43qOk0NE&q=85&s=0054f9b11750e94c0c29918f7b7872be" alt="If Else Second Pn" width="2428" height="1548" data-path="images/ifelse/if_else_second.png" />
</Frame>

### Conditions

Conditions are set in the attributes editor under the **Expressions** section, with each condition (**IF**) having two slots for inputs, and three ways to compare them. You can access the ways to compare by clicking `=`, you will then have the following three options :

<img src="https://mintcdn.com/wordware/GaAvACBL43qOk0NE/images/ifelse/if_else_comparison.png?fit=max&auto=format&n=GaAvACBL43qOk0NE&q=85&s=2c9c6e8d8e3872ac70377f3f3910dae6" alt="If Else Comparison Pn" width="398" height="694" data-path="images/ifelse/if_else_comparison.png" />

| Comparison | How it works                                                                           |
| ---------- | -------------------------------------------------------------------------------------- |
| Match      | Checks if the two values are equal                                                     |
| Text       | Checks if the first value contains the second value                                    |
| Number     | Compares two numeric inputs, with sub-options for the comparison operator (e.g. >, \<) |

You can add as many conditions as you like with the `+ Add If`button below all the existing conditions. There's also an **ELSE** condition, which runs if none of the other conditions are true.

### Actions

Actions are set in the editor under the appropriate condition, allowing for generations, mentions, and any other
node types to be run depending on which condition is true.

The if-else example above, for example, works as follows:

<Steps>
  <Step title="If">
    First, the **IF** condition checks if the `@is_known_user` mention is the
    text "true". If so, the WordApp will run the nodes inside this section:

    <Frame>
      <img src="https://mintcdn.com/wordware/GaAvACBL43qOk0NE/images/ifelse/if_one.png?fit=max&auto=format&n=GaAvACBL43qOk0NE&q=85&s=52d7e859f8b8e0d5f337297f8e15c3f2" alt="If One Pn" width="1002" height="370" data-path="images/ifelse/if_one.png" />
    </Frame>
  </Step>

  <Step title="Else">
    Then, if the above condition *is not met*, the WordApp will run the nodes
    inside this section:

    <Frame>
      <img src="https://mintcdn.com/wordware/GaAvACBL43qOk0NE/images/ifelse/else_two.png?fit=max&auto=format&n=GaAvACBL43qOk0NE&q=85&s=2291c58938931926831b1bdc0d748976" alt="Else Two Pn" width="2134" height="378" data-path="images/ifelse/else_two.png" />
    </Frame>
  </Step>
</Steps>
