Agents in Business Central – part 5 – Creating agent from code
This post explains how to create, configure, and register agents programmatically in Business Central using AL code instead of relying solely on configuration. It covers agent interfaces, capability registration, setup pages, and KPI tracking needed for production-ready, ALM-compatible agent solutions.

post Discover Microsoft Business Central - The wonderful world of Business Central
Key points
- Register the agent as a Copilot capability by extending the Copilot Capability enum and registering it on install
- Implement IAgentFactory to control agent creation, setup experience, and access; implement IAgentMetadata to control runtime display and UI
- Use IAgentTaskExecution to annotate agent messages, offer user intervention suggestions, and set page context such as currency and language
- Create setup pages using PageType ConfigurationDialog with a temporary source table that has a User Security ID field
- Build KPI pages as CardPart pages with cuegroups and a User Security ID field, assigned via the IAgentMetadata implementation
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- enum “Copilot Capability”
- codeunit 4321 “Agent”
- interface “IAgentFactory”
- interface “IAgentMetadata”
- interface “IAgentExperimental”
- interface “IAgentTaskExecution”
Not found in BC28-30: enum “Copilot Capability”, interface “IAgentFactory”, interface “IAgentMetadata”, interface “IAgentExperimental”, interface “IAgentTaskExecution”.
Context
- Features: agent creation from code, capability registration, agent factory interface, agent metadata interface, task execution interface, setup pages, KPI pages, user intervention suggestions
Source: Discover MS BC - Bert Verbeek, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.