# AI

MESA's **AI** tool uses the power of Artificial Intelligence to automatically generate, classify, and analyze your data.&#x20;

The AI tool is powered by ChatGPT and does not require an OpenAI account to access its AI functionality.&#x20;

{% hint style="warning" %}
AI uses Premium tasks. [Learn more](https://docs.getmesa.com/going-further/plans-and-billing#premium-steps)
{% endhint %}

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

### Actions <a href="#action" id="action"></a>

The AI tool includes several defined actions to quickly get you started with common tasks like summarizing, categorizing, and extracting details from your free-form text.

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2Fb77rlSDPOrPW9nLXwtnC%2Fimage.png?alt=media&#x26;token=ffda542c-ece8-4800-b87c-1169d21e558f" alt=""><figcaption></figcaption></figure>

### Prompts <a href="#examples" id="examples"></a>

Provide a prompt to generate a text response within the AI actions. Use the examples below as a starting point. For additional specificity, replace the details in the prompts with MESA Variables from previous steps in your workflow.

![](https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FMlJ7zOCJcPlmDipV0fRo%2Fas-aiprompt.png?alt=media\&token=4ea7bcee-b7ed-4904-b44a-a333d1e6df6e)

```
Write a tagline for an ice cream shop.
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FZSPIrtZ5cOo5yIem1bIp%2Fas-ai-prompt1.png?alt=media&#x26;token=12b00ddc-7c41-49db-ab33-3c5ca74964e8" alt=""><figcaption></figcaption></figure>

```
Write a thank you letter in the form of a poem for John Doe who purchased a Special Agent Widget.
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2Fc0t9gE6xwxbc0GQ4HqIZ%2Fas-ai-promt2.png?alt=media&#x26;token=506f768d-917c-4b90-8c41-db7262f68b81" alt=""><figcaption></figcaption></figure>

```
Write a product description for wooden clogs.
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FRaMqswXNyrajngFNaMfT%2Fas-ai-prompt3.png?alt=media&#x26;token=51657559-f8fe-488a-a707-32df61821c38" alt=""><figcaption></figcaption></figure>

```
Write a blog post to announce our new glow in the dark ice cream.
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FlwPxd8GP4HOU89knyoCy%2Fas-ai-prompt4.png?alt=media&#x26;token=5f12c3c1-d157-4d30-8644-5327cd528915" alt=""><figcaption></figcaption></figure>

### Summarize

This AI action will generate a short summary from paragraph(s) of text.

```
Determine if this is a physical address. Return yes or no.

PO Box 100
1010 NE Main Street
Springfield, MA, 12352
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FWwlIczbYx0lbfRh2R8rX%2Fas-ai-prompt55.png?alt=media&#x26;token=a0030e64-37a3-4647-8345-67db9a81a6d6" alt=""><figcaption></figcaption></figure>

```
Determine if this address is in Europe. Return yes or no.

1010 NE Main Street
Springfield, MA, 12352
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FbQ9qYuOvhrydrwxHLaru%2Fas-ai-prompt6.png?alt=media&#x26;token=43f05e36-2df6-417a-8e3f-34d9e048941a" alt=""><figcaption></figcaption></figure>

```
Determine the gender of this name. Return male, female or unknown:

Alexis Doe
```

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FHlt4zs86nLrA1BskiCvh%2Fas-ai-summarize1.png?alt=media&#x26;token=755ab639-1fce-4f86-98a9-d04183d32d7e" alt=""><figcaption></figcaption></figure>

## Going Further <a href="#limitations" id="limitations"></a>

Check the Advanced > Convert JSON response checkbox on a Prompt step and add a [Loop](https://docs.getmesa.com/tools/loop) step to loop over each result in this prompt:

```
A two-column spreadsheet of top science fiction movies and the year of release. 

Title,
Year of release

Return as json
```

### Other Kinds of AI Steps

There are a multitude of AI actions that are more specific than Prompt or Summarize. [Click here ](https://www.getmesa.com/templates?cat=AI)for our existing AI templates for a few ideas.&#x20;

If none of these actions match what you're trying to do, the Prompt action lets you use any GPT4o-style prompt to fully unlock the potential of artificial intelligence. [OpenAI's example page](https://platform.openai.com/examples/) is an excellent source of inspiration, and the [OpenAI Playground](https://platform.openai.com/playground?mode=chat\&model=gpt-4o) is the easiest way to test and perfect your prompts.

{% hint style="info" %}
We recommend adding an [Approval](https://docs.getmesa.com/tools/approvals) step in your workflow to verify that the prompt output meets your expectations. This is especially useful when fine-tuning your prompt to achieve the desired results.
{% endhint %}

### More Resources <a href="#limitations" id="limitations"></a>

* OpenAI's [Text completion docs](https://platform.openai.com/docs/guides/text-generation) provide examples and best practices around writing prompts.

## Technical Notes <a href="#limitations" id="limitations"></a>

**What is the AI tool powered by?**&#x20;

The AI tool is powered by ChatGPT-4o.&#x20;

**Why should you use ChatGPT (or another service like Claude) instead of MESA's AI-built-in tool?**&#x20;

* ChatGPT reduces MESA premium task usage. Actions associated with Email, SMS, Image, Weather, and AI are Premium steps because we incur the cost of these.&#x20;
* ChatGPT supports more advanced queries
* The AI tool only reads and generates up to 500 words of text. Input text will be truncated after 500 words, and responses will be limited to around 500 words. If you need to analyze or generate long amounts of text, we recommend using MESA's OpenAI app, which allows you to customize the number of tokens to use for each prompt. Most prompts can be copied over from an AI step to an OpenAI prompt step.
* ChatGPT allows you to use your own fine-tuned model

### How AI Uses Your Data <a href="#data-security" id="data-security"></a>

The AI tool makes API calls to OpenAI. Only the variables explicitly configured in the MESA builder will be shared with OpenAI. MESA does not store any of this information beyond your data retention date. OpenAI does not use data submitted to and generated by their API to train OpenAI models or improve OpenAI's service offering.

To opt out of any data sharing with AI models, simply do not use the AI step in any of your workflows.

Learn more about how and when OpenAI is used to train their models: [MESA's Data Processing Agreement](https://www.getmesa.com/dpa).


---

# Agent Instructions: 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:

```
GET https://docs.getmesa.com/tools/ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
