> 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%2Fgit-blob-993a4e70e9356ae2e5124978065dc17e67eb25b2%2Flogic%20Step.png?alt=media" 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%2Fgit-blob-57d22d05153e896eb1684d3c7b188baa4e562d9d%2Fimage%20(262).png?alt=media" 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).
