Skip to main content

Retool AI chat actions

Learn how to generate chat responses with Retool AI.

You can use the Retool AI resource to generate chat responses based on the provided instructions and message history. You can provide text directly in the query, reference existing data from elsewhere (e.g., another query), or use data stored in Retool Vectors.

Get started

To get started with Chat actions for apps, add a new AI Action query. For workflows, add a new AI Action block.

Generate a response

Use the Generate chat response action to generate a response using the provided input and message history. The message history must be formatted as an array of objects with the following properties:

role

string

content

string

When combined with the Chat component and Vectors, this AI Action enables you to build an AI chatbot that can generate responses specific to your needs. Adding a Chat component automatically creates an AI Action query with Generate chat response selected and prefills the input and message history.

  1. Add a Chat component to the canvas.
  2. Enable Use Retool Vectors to provide more context to your query, if required.
  3. Select the AI model to use, (e.g., GPT-4).
  4. Click Save and then Run to perform the action.

The specified AI model then generates a response based on the previous messages and additional input provided.

Like all components, you can access Chat component properties using JavaScript. For example, Chat components have a messageHistory property that contains all messages in the chat log. You can reference specific messages using {{ chat1.messageHistory[0].content }}.