# If Else

Tailwinds allows you to split your chatflow into different branches depending on If/Else condition.

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-f1c0f754287b28b4f8dbfb37ab337c1079e4a1c9%2Fimage%20(5)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2).png?alt=media" alt=""><figcaption></figcaption></figure>

### Input Variables

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-96a22bd6bcced3f9ca915dd57c97b68f40e4661c%2Fimage%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

As noticed from the image above, it takes in any nodes that has `json` output. Some examples are: Custom Function, LLM Chain Output Prediction, Get/Set Variables.

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-2969ad4e2ea346d6cb2eb6fc86ce3e3a5687f302%2Fimage%20(2)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

You can then give a variable name:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-7c8b4107ad9539b8821986945927724a93c02392%2Fimage%20(3)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

This variable can then be used in the [If Function](#if-function) and [Else Function](#else-function) with the prefix `$`. For example:

```
$output
```

### If Else Name

You can name the node for easier visualization of what it does.

### If Function

This is a piece of JS code that is ran on Node sandbox. It must:

* Contains the `if` statement
* Returns a value within `if` statement

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-2e75402816a4cb635d29463e13722890e3968d3c%2Fimage%20(5)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2)%20(1).png?alt=media" alt="" width="312"><figcaption></figcaption></figure>

This gives much more flexibility for users to do complex comparison like regex, date comparsion and many more.

### Else Function

Similar to If Function, it must returns a value. This function will only be ran if the [If Function](#if-function) does not return a value.

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-52dbd74e0cded1b0d83964438d06b92f068b0c9c%2Fimage%20(6)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2)%20(1)%20(1).png?alt=media" alt="" width="317"><figcaption></figcaption></figure>

### Output

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-f4815f46668b28eb03ef2c0753a7e99755bea108%2Fimage%20(8)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

When the [If Function](#if-function) successfully returns a value, it will be passed to the **True** output dot as shown above. This allow users to pass the value to the next node.

Otherwise, the returned value from [Else Function](#else-function) will be passed to the **False** output dot.

User can also take a look at the If Else template in the marketplace:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-6cf7ae39372c918a017b95cda7fcc4de69125af0%2Fimage%20(9)%20(1)%20(1)%20(1)%20(1)%20(2)%20(1)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>
