Drupal AI Views Agent Lets Site Builders Configure Views Using Prompts
Drupal contributor Jibran Ijaz has developed an experimental AI agent that allows site builders to create and update Views using natural language prompts. The feature, documented in a public Drupal.org issue, is built on the Drupal AI agent framework and removes the need to interact directly with the Views UI.
The AI Views agent interprets structured English instructions and translates them into valid Views configuration. For example, users can request a listing view filtered by content type, publication status, or sort order, and the agent generates the corresponding configuration programmatically. The agent supports listing, creating, and updating Views, but does not allow View deletion.
According to Ijaz, the implementation breaks the workflow into three stages: listing existing Views, creating a new View entity, and updating its configuration. Creating a View relies on Drupal’s existing API for generating a basic View entity with default attributes. Updating a View is more complex due to the internal structure of the Views configuration system.
Views configuration is stored as a large key-value map that includes handlers for fields, filters, and sorting, as well as plugins for display style, pagination, access control, and query behaviour. Ijaz developed plugins to insert and update these handlers using the Views data API, allowing the agent to manipulate display settings programmatically.
Managing Views plugins required additional logic, as plugin configurations vary widely in structure and defaults. To address this, separate plugins were created to generate and update plugin settings stored under display options. The final configuration is validated using Drupal core’s Config Schema API before being saved.
For the agent to function, the Views UI module must be enabled and the user must have administer views permissions. This allows the agent to access and modify all enabled Views and their detailed configuration. Ijaz has warned that the feature is experimental and should not be used in production environments.
Development is ongoing through the Drupal AI agents project, with progress tracked via a public development issue and an open merge request on Drupal.org. Ijaz has invited developers to review the implementation and test the feature in local or development environments.


