> 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/ai.md).

# AI

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

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

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

## Configure

### **Skill triggered**

The AI: Skill triggered trigger lets you supercharge your AI prompts by calling MESA workflows to fetch information and take action.

Get started by creating a workflow in MESA with the AI: Skill triggered trigger. Then, let your AI app know about the MESA AI Skill and start chatting.

### **Agent**

The AI: Agent step adds an AI agent to your workflow. Give it instructions, and it works through the task and returns the result for use in later steps.

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FvhjkvZjCiAzYy3umRTui%2Fimage.png?alt=media&amp;token=a71c7ad2-5c2b-4c7d-813e-2164dba74afc" alt="Screenshot of the MESA AI Agent action configuration, default state. Spotlight the Agent action fields."><figcaption></figcaption></figure>

### **Prompt**

The AI: Prompt step generates a text response from your instructions. To get started quickly, choose an option from the **Prompt suggestions** dropdown for common tasks like summarizing, categorizing, or extracting details from free-form text.

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FN73FrGlmc8B6kOuerWYz%2Fimage.png?alt=media&amp;token=f89551e0-057b-4fb6-99eb-6adfbd7357dc" alt="Screenshot of the MESA AI Prompt step configuration, Prompt suggestions dropdown open. Spotlight the Prompt suggestions dropdown."><figcaption></figcaption></figure>

Selecting a suggestion pre-populates the **Message** field, which you can edit to fit your workflow.

#### **Prompt examples**

Write your prompt in the Message field, or start from a Prompt suggestion and edit it. 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.

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FrTBtMJm7GpxxEQZpVFtU%2Fimage.png?alt=media&amp;token=e64aee14-be57-40f5-82ef-23ec038dff52" alt="Screenshot of the MESA AI Prompt step configuration, Message field empty. Spotlight the Message field."><figcaption></figcaption></figure>

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

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

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

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

#### **Classify text**

Use the Prompt step to classify text and return a short, predictable answer. Asking for a specific format, like yes or no, makes the output easier to use in later steps of your workflow.

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

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

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

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

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

Alexis Doe
```

## Going Further

Click the More fields button to check the checkbox for **Response format**, which will allow you to choose the response format of the output:

* **Auto**: will attempt to parse the response as a JSON object if it is valid JSON.
* **Text**: will return the response as a string.
* **JSON Object**: will return the response as a JSON object.

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FD3HTrYZOdVhh4e2GQOOf%2Fimage.png?alt=media&amp;token=c17c845a-e8f6-4b88-be02-f2c0172f5da1" alt="Screenshot of the MESA AI Prompt step configuration, Response format field added via the More fields button. Spotlight the Response format dropdown."><figcaption></figcaption></figure>

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
```

Click the More fields button to check the checkbox for **Web Search**, which will allow the action to search the internet while evaluating the prompt.

#### **Finding prompt ideas**

The Prompt suggestions dropdown covers common tasks, and our [AI templates](https://www.getmesa.com/templates?cat=AI) offer more ideas.

If none of the suggestions match what you're trying to do, write your own instructions in the Message field. The Prompt step accepts any GPT-4o-style prompt. [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**

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

## Technical Notes

**What is the AI tool powered by?**

* The AI tool is powered by ChatGPT-4o.

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

* 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.
* 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**

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
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/ai.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.
