> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guides/blocks/if-else-if-and-else.md).

# If, Else if and Else

#### 1. Conditional block (If)

If is the command block that checks a specific condition first. If that condition is True, the system will execute all the actions placed within this If block. If False, the system will skip it and check further down.

#### 2. Additional conditional block (Else if)

Else if always follows the If block (or follows another Else if). This block is activated when all the conditions above it are False. The system will check its own condition, if True then execute the actions inside, if False then skip again.

> You can add multiple Else if blocks in succession to check different scenarios of the script.

#### 3. Negation block (Else)

Else is the final wrapping command block in the condition chain and does not require any conditions to be configured. When all the If and Else if blocks above are False (no case is satisfied), the system will automatically jump in and execute the actions inside the Else block.

<figure><img src="/files/nhmHdpIfLex1CNdAIRa0" alt=""><figcaption></figcaption></figure>

#### Real-world example: Checking the login status of an account

When you open a website (for example: Facebook, X...), the status of the account on the profile may vary. You can use the If - Else if - Else chain to smoothly handle all situations:

* If: See the "Create Post" button (Proving the account is already logged in).
  * *Action*: Proceed to fill in the content and post it immediately.
* Otherwise if: See the "Username / Password" input box (The account has been logged out).
  * *Action*: Call data from variables to fill in the account, password and click Login.
* Otherwise all: Do not see the Post button and do not see the Login box (The account may have been checkpointed or there is a network error).
  * *Action*: Use the Stop command to halt the program or take a screenshot to check later.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-en/action-guides/blocks/if-else-if-and-else.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
