---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, AI Widgets, widgets, tags, UI components]
nav: wcp_docs
parent_url: /wcp_docs/
title: aiPrompt in richText
layout: subsection
---

For Extend Professional customers: `aiPrompt` is a [richText](/wcp_docs/aao1512514194210.html) tag attribute that generates content based on input AI prompts and values. The `richText` widget initially displays its value on page load or as a result of an event. After a user clicks a pre-configured AI prompt, a popup window displays the generated content and enables the user to insert or replace the current value of the `richText` widget.

Specify these `aiPrompt` attributes:

-   <b>buttons</b>

    A list containing 1 or more buttons that display at the bottom of the `richText`.

    Each button contains these attributes:

    -   <b>label</b>

        (Required) A string script containing the button label.

    -   <b>prompt</b>

        (Required) A string script containing a dynamic AI prompt. The script can include variables and references to any tag attributes on the page.

    -   <b>dependencyTags</b>

        (Optional) A list containing the string IDs of other `text` or `richText` tags that enable the AI prompt. If you don’t specify `dependencyTags`, the prompt button is always enabled. If you specify `dependencyTags`, the prompt button is only enabled when all tags in `dependencyTags` have values.




## Example in Visual Mode

This example assumes a `text` tag with id=<i>JobTitle</i> and a `richText` tag with id=<i>jobDescription</i>.

<b>Presentation tab</b> &gt; <b>Rich Text</b> &gt; <b>AI Prompt</b>

<table><thead><tr><th>Attribute</th><th>Example Value</th></tr></thead><tbody><tr><td><b>Buttons[0]</b></td><td> </td></tr><tr><td>Label</td><td>Generate Job Description (150 words)</td></tr><tr><td>Prompt (Change to Scripted Value)</td><td>`Create a job description around 150 words for {{jobDescription.value}}. The response should avoid bias. The response should have a friendly yet professional tone.`</td></tr><tr><td>Dependency Tags</td><td>jobTitle</td></tr><tr><td><b>Buttons[1]</b></td><td> </td></tr><tr><td>Label</td><td>100 words</td></tr><tr><td>Prompt (Change to Scripted Value)</td><td>`Summarize the following text to 100 words: {{jobDescription.value}}. The response should avoid bias. The response should have a friendly yet professional tone`</td></tr><tr><td>Dependency Tags</td><td>jobDescription</td></tr></tbody></table><br/>

## Example in Code Mode

This page snippet includes:

-   A `text` tag that accepts an input job title.
-   A `richText` tag with the `aiPrompt` attribute containing prompts for generating content based on input and length.


```
{
 "type": "text",
 "id": "jobTitle",
 "label": "Job Title",
 "value": "Senior Software Engineer"
},
{
 "type": "richText",
 "id": "jobDescription",
 "label": "Job Description",
 "aiPrompt": {
   "buttons": [
     {
       "label": "Generate Job Description (150 words)",
       "dependencyTags": ["jobTitle"],
       "prompt": "<% `Create a job description around 150 words for {{jobDescription.value}}. The response should avoid bias. The response should have a friendly yet professional tone.` %>"
     },
     {
       "label": "List format",
       "dependencyTags": ["jobDescription"],
       "prompt": "<% `Summarize the following text to 100 words: {{jobDescription.value}}. The response should avoid bias. The response should have a friendly yet professional tone.` %>"
     }
   ]
 }
}
 
```

## <a id="section_1"></a>Adding Dynamic Values in the AI Prompt

This section contains examples of adding dynamic values in an AI prompt.

Sample `dynamicSection` with dynamic data in AI prompt using `pageVariables`:

```
{
  "type": "dynamicSection",
  "id": "dynamicButtonLabel",
  "data": "<% '' %>",
  "dataVariableName": "buttonLabel",
  "children": [
    {
      "type": "richText",
      "id": "<% pageVariables.buttonLabel = buttonLabel; 'hello'; %>",
      "aiPrompt": {
        "buttons": [
          {
            "label": "Generate",
            "prompt": "Give me a few sentences about <% pageVariables.buttonLabel %>" 
          }
        ]
      } 
    }
  ]
}
```

Sample AI prompt using `queryParams`:

```
{
  "type": "richText",
  "id": "hello",
  "aiPrompt": {
    "buttons": [
      {
        "label": "Generate",
        "prompt": "Give me a few sentences about <% queryParams.input %>"
      }
    ]
  } 
}
```

Sample AI prompt using a function in a script module:

```
{
  "type": "richText",
  "id": "hello",
  "aiPrompt": {
    "buttons": [
      {
        "label": "Generate",
        "prompt": "Generate a welcome greeting in <% myScript.getCountry(1) %>. We want less than 5 words in response."  
      }
    ]
  }
}
 
```

