Edit

Coding agents in AL (preview)

[This article is prerelease documentation and is subject to change.]

Important

  • This is a preview feature.

  • This preview feature is supported in production environments, but we recommend that you experiment and test thoroughly in a sandbox environment first. These features might have restricted functionality and are subject to supplemental terms of use.

  • This article is primarily intended for product owners, domain experts, consultants, and developers who want to experiment with AI capabilities in Business Central using the AI development toolkit.

In AL, you find interfaces and codeunits designed for building custom AI agents in Business Central. This article provides an overview of these tools and links to detailed documentation for each area.

Important

This capability is available for sandbox environments for evaluation purposes from 27.4. Starting from version 28.1, production environments are also supported.

Important

Before deploying agents to a production environment, it's highly recommended to define and run thorough tests in a sandbox environment. Learn more in Best practices for designing an agent (preview).

Quick-start

To quickly get started with a template agent that, you can customize to your needs; press Ctrl+Shift+P and start typing AL: New Project command in Visual Studio Code to choose the Agent template. This provides you with a skeleton of an implementation, which covers most of the topics discussed in this documentation.

Core interfaces

To define an agent in AL, you need to extend the enum that defines the available types of agents and implement three core interfaces:

Interface Purpose
IAgentFactory Defines how agent instances are created and configured, including default settings, setup pages, and creation rules.
IAgentMetadata Provides runtime metadata for individual agent instances, such as initials, setup pages, summary pages, and annotations.
IAgentTaskExecution Controls how agents process and execute tasks, including message analysis, user intervention suggestions, and page context.

Learn more in Define and register an agent programmatically (preview).

Setup and configuration

Once you've defined your agent type, you need to create setup pages and configure agent instances:

  • Setup pages: Create configuration dialogs using the ConfigurationDialog page type
  • Agent Setup codeunit: Use helper methods for UI-based agent configuration
  • Agent configuration: Set display names, profiles, localization, permissions, and access controls
  • Instructions: Define static or dynamic instructions for your agent

Learn more in Agent setup and configuration (preview).

Managing agent tasks programmatically

The API for building agents provides codeunits to trigger and manage agent tasks programmatically:

  • Agent Task Builder API: Create tasks from page actions, business events, or email triggers
  • Attachments: Add documents for agents to process
  • Task lifecycle: Monitor and control running tasks
  • Agent sessions: Detect agent sessions and bind events for task duration
  • Cross-agent operations: Create public APIs to allow other apps to interact with your agent

Learn more in Managing agent tasks programmatically (preview).

Define and register an agent programmatically (preview)
Agent setup and configuration (preview)
Managing agent tasks programmatically (preview)
Overview (preview)
Designing and coding agents (preview)
Integrate with the Tasks AL API (preview)
Create and activate (preview)
Write effective instructions (preview)
Instruction keywords (preview)
Set up permissions and profiles (preview)
Run an agent (preview)
Iterate and manage (preview)
Best practices for designing an agent (preview)
Best practices (preview)
Create a Sales Validation Agent (preview)
Transparency note: Business Central AI development toolkit (preview)