> For the complete documentation index, see [llms.txt](https://docs.getmesa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getmesa.com/tools/logic.md).

# Logic

The **Logic** tool lets you contain all of the inner workings of your workflow--filtering, restructuring and looping data--in a single, reliable step. The MESA AI assistant can help you build and adjust the logic.

## Configure <a href="#overview" id="overview"></a>

### Building a Logic workflow

Start by opening the MESA AI assistant and asking it to `Build a workflow`. For example:

{% code overflow="wrap" %}

```
Build a workflow that sends Shopify orders over $100 with an "uploadery_1" line item to Google Sheets
```

{% endcode %}

The MESA AI assistant will look for similar templates. If you decline the template install, it will ask a few clarifying questions, outline your workflow, and get to work adding your trigger, Logic step and action(s). As part of the workflow building, the MESA AI assistant will write the logic script and build a diagram outlining your workflow's logic:

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FPv5eC8MaPiWi6UUwzFcv%2Flogic%20Step.png?alt=media&amp;token=49cd302b-6e86-4453-bd74-a77e7ad1fc75" alt="Screenshot of a Logic step built by the MESA AI assistant in the MESA workflow builder showing the generated logic script and workflow diagram, spotlight the Logic step diagram."><figcaption></figcaption></figure>

Once your workflow is built, the MESA AI assistant will let you know what needs to be done to complete the workflow setup, then walk you through manually running it to confirm it is working as expected. Describe any changes you need to make to the MESA AI assistant. If everything looks good, turn on your new workflow.

### Editing a Logic step

The easiest way to edit a logic step is by clicking the Edit with MESA AI button at the bottom of the Logic step. The MESA AI assistant will read your workflow and walk you through making the updates.

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2Fk4uQFLj9NMIDdnTKkCUH%2Fimage.png?alt=media&amp;token=34e2887c-1e34-4027-b776-40dab11d9141" alt="Screenshot of a Logic step opened in the MESA workflow builder, spotlight the Edit with MESA AI button at the bottom of the step."><figcaption></figcaption></figure>

If you are technical and would like to get under the hood, you can edit the Logic code. Click on `...` > `Edit Code`, and you can edit the JavaScript code powering the Logic step with the [MESA SDK](/tools/custom-code/libraries/sdk.md).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.getmesa.com/tools/logic.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
