﻿---
title: Create and manage AI index automations
description: Create, inspect, run, schedule, update, and remove the workflow automations that generate Knowledge Indicators.
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/create-and-manage-automations
products:
  - Elastic Documentation
  - Elastic Observability
  - Elastic Security
  - Elasticsearch
  - Kibana
applies_to:
  - Elastic Cloud Serverless: Experimental
  - Elastic Stack: Planned
---

# Create and manage AI index automations
<important>
  This page is currently hidden from the documentation navigation.The following Context Engine pages are live:
  - [Landing page](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine)
    - [Context Engine quickstart](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/quickstart)
  - [Context Engine concepts](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/concepts)
  - [Build and maintain an AI index](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/build-and-maintain-ai-index)
    - [Create and manage AI indices](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/create-and-manage-ai-indices)
  - [Add and manage sources](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/add-and-manage-sources)
  - [Create and manage automations](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/create-and-manage-automations)
  - [Manage KIs](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/inspect-and-manage-knowledge-indicators)
  - [Evaluate and improve KIs](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/evaluate-and-improve-knowledge-indicators)
  - [Use an AI index](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/use-an-ai-index)
    - [Retrieve context](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/retrieve-context-from-ai-index)
  - [Save and retrieve memories](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/save-and-retrieve-memories)
  - [Configure agents to use an AI index](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/use-context-engine-with-agents)
    - [Use Context Engine with Agent Builder](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/use-context-engine-with-agent-builder)
  - [Query AI indices from LangChain](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/langchain-integration)
  - [Context Engine APIs](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/context-engine-api)
</important>

Automations generate and refresh Knowledge Indicators (KIs) from an AI index's sources. Context Engine runs each automation as an [Elastic workflow](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/workflows). You can have Elastic Agent Builder propose and pilot one, author one in the Workflows UI, or manage workflows and their AI index associations programmatically.

## Before you begin

You need a custom AI index with at least one source, the **All** privilege for the **Context Engine** feature, and permission to create and manage workflows. To use the guided route, you also need access to Elastic Agent Builder and permission to run workflows.
Decide what each KI should represent before creating an automation. Refer to [Select a generation strategy](/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/build-and-maintain-ai-index#select-a-generation-strategy) and [Design useful Knowledge Indicators](/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/build-and-maintain-ai-index#design-useful-knowledge-indicators).

## Create an automation with Agent Builder

Use the guided route to have Elastic Agent Builder propose and set up an automation for the AI index:
1. Open **Context**, then select the AI index.
2. In the **Automations** section, select **Add automation** → **Create with AI Agent**.
3. Elastic Agent Builder opens in the side panel and sends **Suggest an automation for this AI index.**
   If this browser already has a conversation for this AI index in the current space, Elastic Agent Builder reopens it. The browser remembers one conversation for each AI index in each space.
   To start over:
   1. Click **Open navigation menu** at the top of the panel.
2. Click **New chat**.
3. Select **Add automation** → **Create with AI Agent** again.
   If you send a message in the new chat, or select a different chat from that menu, that conversation is the one that reopens next time.
4. Review the generation strategy that Elastic Agent Builder proposes and the evidence it cites from your data.
   For an AI index without automations, Elastic Agent Builder chooses the strategy from the data. It asks you to choose in these cases:
   - The description covers more than one recurring entity, such as products and customers. It asks which entity to profile.
- Two strategies fit about equally, or the data doesn't show what the AI index is for. It asks you to choose a strategy.
   For an AI index that already has automations, it asks what you want to achieve.
5. What happens next depends on the strategy:
   - **Index/Table Metadata, Bottom-Up, Cumulative / Wiki-style, and Targeted KI**: Elastic Agent Builder installs a template and attaches the automation to the AI index. The install has no confirmation prompt. When one strategy clearly fits, it installs without asking you to approve it in chat.
- **Other strategies**: Elastic Agent Builder asks you to confirm a plan before it builds anything:
  1. Review the plan, which includes the strategy, sources, corpus filter, and expected cost. Ask for changes where necessary, then confirm.
2. Elastic Agent Builder builds and pilots the workflow, removes the temporary KIs that the pilot wrote, and summarizes the results. Review the summary.
3. In the confirmation prompt, select **Save and attach**. If the workflow replaces an existing automation, select **Replace** instead.
6. Confirm the run:
   - For an Index/Table Metadata, Bottom-Up, or Cumulative / Wiki-style automation that would write more than five KIs, the first prompt is a pilot of five items. Select **Run pilot**. **Cancel** is the other button.
- Otherwise, select **Run automation** or **Cancel**.
- A Targeted KI automation is the exception. Elastic Agent Builder runs it without this prompt.
   To run the automation later:
   - Ask Elastic Agent Builder again.
- In the **Automations** section of the AI index, from the actions menu (`ellipsis`) for the automation, select **Run** after the workflow is enabled.
- [Run it from the Workflows UI](#run-schedule-and-monitor-an-automation).
   If the pilot writes a KI for each item, Elastic Agent Builder estimates how long the full run takes. Select **Run automation**.
   If the pilot fails, or doesn't write a KI for each item, Elastic Agent Builder reports the problem and stops. The pilot writes real KIs, which the full run replaces. If you cancel the full run, the pilot's KIs stay in the AI index.
7. The full run continues in the background. To check on it, ask Elastic Agent Builder for a progress update.
8. Return to the AI index and confirm that the workflow appears in the **Automations** section.

When Elastic Agent Builder builds a workflow for a strategy that has no template, it pilots the workflow and deletes the temporary KIs the pilot wrote before you save it. Focus your review on the source data it reads, what each KI represents, the claims and query guidance it generates, and the checks it performs before writing a KI. You do not need to understand every line of the generated YAML.

## Create an automation manually

Use the manual route when you intend to author the workflow yourself:
1. Open the AI index. In the **Automations** section, select **Add automation** → **Create workflow**.
2. Context Engine creates and attaches a workflow with **Enabled** turned off, then opens it in the Workflows YAML editor.
3. Replace the generic starter workflow with the trigger and steps that generate the intended KIs.
4. Include the appropriate Context Engine workflow steps to create, update, verify, or delete KIs.
5. Test the workflow, review its output, then save it.
6. Return to the AI index and confirm that the workflow appears in the **Automations** section.

For YAML editing and test runs, refer to [Use the YAML editor](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/workflows/authoring-techniques/use-yaml-editor).

## Inspect or edit an automation

The AI index lists each attached workflow and whether it is enabled.
To inspect or edit one:
1. Open the AI index.
2. In the **Automations** section, from the actions menu (`ellipsis`) for the automation, select **View** to inspect the workflow YAML without leaving the page.
3. To edit the workflow, from the actions menu, select **Open in Workflows**.
4. Make and test the required changes, then save the workflow.

Saving a workflow creates a versioned snapshot. For information about comparing or restoring versions, refer to [Workflow version history](/elastic/docs-content/pull/9070/explore-analyze/workflows/authoring-techniques/manage-workflows#workflows-version-history).

## Run, schedule, and monitor an automation

Operate an automation from the Workflows UI:
- [Run the workflow manually](/elastic/docs-content/pull/9070/explore-analyze/workflows/authoring-techniques/manage-workflows#workflow-run) to generate or refresh KIs immediately.
- Add a [scheduled trigger](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/workflows/triggers/scheduled-triggers) when its KIs must refresh automatically.
- [Monitor the execution](/elastic/docs-content/pull/9070/explore-analyze/workflows/authoring-techniques/monitor-workflows#workflows-monitor-execution) and inspect the inputs, outputs, and errors for each step.
- Use the **Enabled** toggle to control whether the workflow responds to its configured triggers.

After a successful run, return to the AI index's **Knowledge Indicators** tab and confirm that the expected KIs were created or updated.
<tip>
  To steer an Elastic Agent Builder agent toward the generated KIs, open **Manage components → Agents**, create or edit an agent, and add the AI index in its settings. For the complete setup and testing flow, refer to [Use Context Engine with Elastic Agent Builder](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/use-context-engine-with-agent-builder).
</tip>


## Detach or delete an automation

Removing an automation from an AI index detaches its workflow. It does not delete the workflow itself.
Detach an automation as follows:
1. Open the AI index.
2. In the **Automations** section, from the actions menu (`ellipsis`) for the automation, select **Delete**.
3. In the confirmation dialog, select **Remove**. The change is saved immediately.
4. Confirm that the automation no longer appears in the AI index.

To delete the detached workflow, delete it separately from the Workflows UI. You can also choose to delete attached automations when you [delete the AI index](/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/create-and-manage-ai-indices#delete-an-ai-index).

## Manage automations with the APIs

Use the Workflows APIs together with the Context Engine APIs when you need to provision or operate automations programmatically:
1. Create the workflow with the [create workflow API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-post-workflows-workflow), or modify an existing workflow with the [update workflow API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-put-workflows-workflow-id). Use the [get workflow API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-get-workflows-workflow-id) to retrieve its current definition before changing it.
2. Attach the workflow by adding its ID to the AI index's `automations` array with the [create or update AI index API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-put-context-engine-ai-index-aiindexid):
   ```json
   {
     "automations": [
       {
         "type": "workflow",
         "value": "my-workflow-id"
       }
     ]
   }
   ```
3. Run it with the [run workflow API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-post-workflows-workflow-id-run), or enable its configured trigger. Use the [get workflow executions API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-get-workflows-workflow-workflowid-executions) to inspect its runs.
4. To detach it, remove its entry from the AI index's `automations` array. To remove the workflow itself, use the [delete workflow API](https://www.elastic.co/docs/api/doc/kibana/operation/operation-delete-workflows-workflow-id) separately.

Updating an AI index replaces its complete record. For an example that preserves the other fields, refer to [Update an AI index with the API](/elastic/docs-content/pull/9070/explore-analyze/ai-features/context-engine/create-and-manage-ai-indices#update-ai-index-api).