[META] Drupal AI Views Agent
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3539458. -->
Reported by: [jibran](https://www.drupal.org/user/1198144)
>>>
<p>The detailed document can be found at <a href="https://docs.google.com/document/d/16yCLk7Q7WWbbqH9PxD6yJX9VufHNUqEWOGCWJqdbg30/edit?usp=sharing">https://docs.google.com/document/d/16yCLk7Q7WWbbqH9PxD6yJX9VufHNUqEWOGCWJqdbg30/edit?usp=sharing</a></p>
<h2>Summary</h2>
<p>This issue outlines the scope, technical specifications, and user stories for a new Drupal AI Views Agent feature, designed to integrate AI capabilities into the Drupal Views module. The core objective is to enable users to create and configure Drupal Views using natural language instructions, leveraging Large Language Models (LLMs) and the existing Drupal AI Agent framework.</p>
<h3>Introduction and Scenarios</h3>
<p>The Drupal AI Views Agent will enhance the Views module by allowing users to interact with it through natural language. This feature will utilize Drupal AI agents and sub-agents to interpret user commands and translate them into specific Views configurations.</p>
<h4>Sample scenarios include:<br>
</h4>
<ul>
<li>An event organizer wants to create a display for upcoming events to show on a homepage.</li>
<li>A non-profit organization wants to add a latest article listing to their homepage for awareness.</li>
</ul>
<p>These scenarios are created based on <a href="https://new.drupal.org/assets/2025-06/Drupal-AI-Strategy-June-25_0.pdf">https://new.drupal.org/assets/2025-06/Drupal-AI-Strategy-June-25_0.pdf</a>.</p>
<h3>Scope</h3>
<p>The project's scope covers:</p>
<ul>
<li>Development of the Drupal AI Views Agent for interpreting natural language to configure Views.</li>
<li>Integration with the existing Drupal AI Agent framework.</li>
<li>Identification and conversion of key parameters from natural language input (e.g., content type, display type, fields, filters, sorting)</li>
<li>Programmatic creation and configuration of a new View based on extracted parameters.</li>
<li>Support for common Views features: display types (block, page), style types (listing, table, grid), fields/view modes, filters (content type, status, arguments), sorting, content limits, headers/footers, and access control.</li>
</ul>
<h3>Technical Specifications</h3>
<p>The Drupal Views AI Agent will process natural language instructions using an LLM to derive specific Views parameters.</p>
<h4>An example instruction: </h4>
<p>"Create a block display to show the latest 9 published articles in a 3 by 3 grid. Each article in the grid should show the title of the article, the image of the article, the summary of the article, and a read more link to the article."</p>
<p>Extracted parameters from this instruction would include:</p>
<ul>
<li>Content type: <code>article</code></li>
<li>Display type: <code>block</code></li>
<li>Style type: <code>grid</code></li>
<li>Style specific options: <code>3x3</code></li>
<li>Fields to use: <code>title, summary, image, link to the article</code></li>
<li>Limit: <code>9</code></li>
<li>Sort order: <code>published date descending</code></li>
<li>Content status: <code>published</code></li>
</ul>
<p>These parameters will then be passed to a function call plugin to create the view.</p>
<h3>User Stories</h3>
<p>The user stories for covering the AI agent's ability:</p>
<table>
<thead>
<tr>
<th>User Story</th>
<th>Description</th>
<th>Views Plugin/ Feature</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>As a Site Administrator, I want to create a new View using natural language instructions, so that I can quickly and intuitively build content listings.</strong></td>
<td>This involves the core functionality of the Drupal Views AI agent, processing natural language, and converting it to Views configurations.</td>
<td>Programmatically create a view</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want the AI agent to support various display types (e.g., block, page) when creating a View, so that I can generate different types of content presentations.</strong></td>
<td>This user story focuses on the agent's ability to correctly identify and apply display type parameters.</td>
<td>Views Display plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want the AI agent to understand and apply different display styles (e.g., listing, table, grid), so that I can control the visual layout of my content.</strong></td>
<td>This user story covers the agent's capacity to interpret and configure style type options, including specific grid dimensions.</td>
<td>Views Style plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want to specify which fields to display in a View using natural language, so that I can control the information presented for each content item.</strong></td>
<td>This user story involves parsing field names from natural language and mapping them to available Drupal fields.</td>
<td>Views FIeld plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want to apply filters (e.g., content type, status) to a View using natural language, so that I can narrow down the content displayed.</strong></td>
<td>This focuses on the agent's ability to identify and configure filters based on natural language input.</td>
<td>Views Filter/Argument plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want to set the sorting order of content in a View using natural language (e.g., "latest", "alphabetical"), so that I can organize my content effectively.</strong></td>
<td>This user story covers the agent's interpretation of sorting instructions and mapping them to Views sorting criteria.</td>
<td>Views Sort plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want to specify a limit on the number of content items displayed in a View using natural language, so that I can control the length of my listings.</strong></td>
<td>This involves the agent's ability to extract and apply numerical limits.</td>
<td>Views Pager plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want the AI agent to be able to ask clarifying questions if my initial instruction is ambiguous or incomplete, so that the View can be configured correctly.</strong></td>
<td>This user story addresses the iterative nature of agent-based interactions and handling incomplete information.</td>
<td>Misc</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want to define specific access permissions for a View using natural language (e.g., "only authenticated users"), so that I can control who sees my content.</strong></td>
<td>This focuses on the agent's ability to integrate with Drupal's access control mechanisms.</td>
<td>Views Access plugins</td>
</tr>
<tr>
<td><strong>As a Site Administrator, I want to add headers and footers to a View using natural language, so that I can provide additional context or branding.</strong></td>
<td>This involves the agent's capability to identify and apply header and footer content.</td>
<td>Views Area plugins</td>
</tr>
<tr>
<td><strong>As a Developer, I want a well-documented API for interacting with the Drupal Views AI Agent, so that I can extend its functionality or integrate it into other modules.</strong></td>
<td>This user story addresses the need for clear technical documentation and a robust API.</td>
<td>Documentation</td>
</tr>
</tbody>
</table>
<h3>Future Considerations</h3>
<p>Future enhancements may include:</p>
<ul>
<li>Advanced filtering options (date ranges, taxonomy terms, user fields).</li>
<li>Relationship support between content types.</li>
<li>Contextual filters/arguments.</li>
<li>Exposed filters.</li>
<li>Internationalization for multi-language support.</li>
</ul>
<h3>Risks</h3>
<p>Potential risks identified are:</p>
<ul>
<li>LLM inaccuracies.</li>
<li>Complexity of the Views module.</li>
<li>Performance overhead.</li>
<li>Security vulnerabilities from natural language interpretation.</li>
<li>Instability and breaking changes due to ongoing Drupal AI module development.</li>
</ul>
<h3>Next Steps</h3>
<p>The next steps involve:</p>
<ol>
<li>Review and approval of this document.</li>
<li>Detailed technical design phase.</li>
<li>Establishment of a comprehensive project plan and timeline.</li>
<li>Commencement of development.</li>
</ol>
<h3>Flow Chart</h3>
<p>The sample workflow for the agent.</p>
<h4>Core Processes</h4>
<p><img src="https://www.drupal.org/files/issues/2025-08-25/core-processes.png" alt=""></p>
<h4>Process 1: List View</h4>
<p><img src="https://www.drupal.org/files/issues/2025-08-25/list-view.png" alt=""></p>
<h4>Process: 2: Create View</h4>
<p><img src="https://www.drupal.org/files/issues/2025-08-25/create-view.png" alt=""></p>
<h4>Process 3: Update View</h4>
<p><img src="https://www.drupal.org/files/issues/2025-08-27/sub-processes.png" alt=""></p>
<h4>Views Agent</h4>
<p><img src="https://www.drupal.org/files/issues/2025-08-25/views-agent.png" alt=""></p>
<p>The detailed document can be found at <a href="https://docs.google.com/document/d/16yCLk7Q7WWbbqH9PxD6yJX9VufHNUqEWOGCWJqdbg30/edit?usp=sharing">https://docs.google.com/document/d/16yCLk7Q7WWbbqH9PxD6yJX9VufHNUqEWOGCWJqdbg30/edit?usp=sharing</a></p>
> Related issue: [Issue #3542457](https://www.drupal.org/node/3542457)
issue