Skip to main content

Retool AI actions

Learn about AI actions to write instructions for AI models.

The Retool AI resource enables you to write queries that instruct AI models to perform different actions:

Text actions

Use Text actions to generate and analyze text content. You provide an instruction and select the model to use.

The response is made available on the data query property. Rather than waiting until the full response is generated, Retool receives the response stream. This allows the AI model to immediately respond so you can see the response appear in real time.

Generate text

The Generate text action generates text-based content from the input instructions. This is useful if you need some initial content or sample data. For example, you can generate a product description:

Write a creative product description for a mechanical keyboard named VelocityX Pro, with the keywords "fast responsiveness", "ergonomic", "gaming-optimized" for a software developer who enjoys gaming, and describe the benefits of this product in 100 words.

Summarize text

The Summarize text action generates a summary of the input text. For example, you can provide the text from a blog post and generate a concise summary:

Retool blog post:

Retool started six years ago as a frontend builder for internal tools. Since we launched, we’ve worked with tens of thousands of companies across every vertical—from two-person startups all the way to Fortune 10s. We focused on making it as fast as possible for developers to build internal apps so that they don’t have to start from scratch to build the same patterns of admin panels, CRUD apps, frontends for APIs, automations, etc.[...]

Classify text

The Classify text action analyzes the input text and classifies it based on the specified labels. This can be useful if you need to perform sentiment analysis or categorize customer requests in some way.

I was pleasantly surprised by the water bottle's elegant design and excellent insulation, which kept my water cool for an extended period.

Classification labels: positive, negative, neutral

Extract entity from text

The Extract entity from text action analyzes the input text and identifies information based on the specified entities. For example, you can extract the product name and Return address entities from the following message:

Dear Mandy,

Your return request for the product, LunarStride Pro, has been declined due to not meeting the required condition for acceptance. We will be shipping this back to 1234 Elm Street, Springfield, CI 56789.

Chat actions

Use Chat actions to generate message responses based on context from the conversation history and any additional provided data. The Chat component for web apps has built-in support and automatically creates an AI Action query to generate chat responses.

Generate chat response

The Generate chat response action can respond to conversations with users based on the messages previously sent. You can use this action to create an AI chatbot on Retool.

The Message history requires a JSON array of objects with the following properties:

PropertyDescription
roleThe participant in the conversation. Either user for the participant sending messages (i.e., the user) or assistant for the participant responding to messages (i.e., the AI responses).

[
{
"role": "user",
"content" "hello"
},
{
"role": "assistant",
"content" "hello"
},
]

Document actions

Document actions are only available in Retool apps.

Use Document actions to parse and analyze text from documents you upload or are available in a data store, such as Amazon S3.

Convert document to text

The Convert document to text action analyzes the contents of a file and returns the text it contains. You can connect the action to a File Input component or reference a file using {{ }} notation, such as a file retrieved from a data store.

The AI model processes the document, extracts the text, and returns it in the response.

Image actions

Use Image actions to generate images based on the provided input.

Generate image

The Generate image action produces images based on the input prompt, then returns a base64-encoded PNG image. This can be used as the value for an Image component or downloaded using utils.DownloadFile().

A close up, studio photographic portrait of a white siamese cat that looks curious, backlit ears.