AI Actions: variables
AI Action variables define the inputs editors provide when executing an AI Action, shaping workflows and ensuring context-aware results. They give editors control over how AI adapts to specific content needs, allowing for greater flexibility while keeping AI-driven processes aligned with company goals.
Types of Variables
The following gives a description and example use cases for the types of variables you can use in Contentful’s AI Actions.
Entry variable
The Entry variable allows you reference existing content within Contentful, such as the current entry or another entry, to provide context for an AI Action. This ensures the AI can interact with or modify specific content based on your needs.
For example, if you're using AI Actions for rewriting, translating, or personalizing content, the Entry variable can point to a product description, blog post, event details, target audience, case study, or FAQ. This allows the AI to generate more relevant and context-aware outputs tailored to your content strategy.
How it works: specify the content you want the AI to modify by selecting the corresponding field in the entry.
Example use case: if you want to translate a product description, you can create a variable that references the content of that field: “Translate the [Content] in the product description field to [language].”
Multiple choice variable
A Multiple Choice variable allows the user to select from a list of predefined options. This is especially useful when you need the AI to make decisions or tailor its actions based on specific choices provided by the user.
For example, if you’re implementing an AI Action that rewrites content for different tones, you can present the user with a list of tone options (e.g., Formal, Casual, Friendly) and the AI will apply the appropriate tone based on their selection.
How it works: select an option from a list and the AI then uses that choice to adjust its behavior or output accordingly.
Example use case: “Choose the tone for the rewritten content: Formal, Casual, Friendly.”
Locale variable
A Locale variable allows the user to select a locale that has been configured in your Contentful space. This is ideal when you need to customize content based on different languages or regions.
For example, when translating content, you can use the Locale variable to specify the target language or locale, ensuring that the translation aligns with the appropriate regional nuances.
How it works: select a locale from the list of available locales configured in the Contentful space. The AI then tailors its actions (such as translation or localization) based on that locale.
Example use case: “Translate the article to Spanish (Mexico).”
Media variable
A Media variable allows the user to select a media asset (such as an image) from your Contentful space or the current entry. This is useful when your AI Action involves working with visual or media-rich content, such as generating image captions or media descriptions, or replacing media assets in content.
How it works: select a media asset, and the AI Action can then refer to or manipulate that asset in the context of the task (e.g., generating alt text for an image).
Example use case: “Generate an alt text description for the selected image.”
Best practices: variables
The following list includes ways to incorporate variables into your AI Actions:
Create or Customize an AI Action: Start by creating a new AI Action or customizing an existing template. This can be done through the AI Actions page under the “AI & Automations” tab.
Add Variables: In the instructions section of your AI Action, insert the appropriate variable type by selecting the corresponding placeholder. For example, you can reference a text field, set up a list of choices for the user to select from, or define a locale and media asset for the AI to use.
Test and Refine: After configuring your AI Action, use the Playground to test it. This allows you to see how the AI Action behaves with the selected variables and make adjustments if necessary.
Publish the Action: Once you’re satisfied with the AI Action, click "Publish" to make it available for use in the entry editor.