---
id: post/bertverbeek-nl/1272
type: post
title: Agents in Business Central – part 5 – Creating agent from code
summary: 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.
tier: community
language: en
tags:
  - agents
  - copilot
  - al development
  - code-based agents
  - agent registration
  - interfaces
  - setup pages
  - kpi tracking
system: copilot
review:
  state: reviewed
  by: opus
  at: "2026-10-08T01:56:44.042Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: e2ecf8f0717af7370841433c2cff04786e4b1be33fa81936a19a297f53b5fa0e
evidence:
  - kind: blog
    url: https://www.bertverbeek.nl/blog/2026/02/23/agents-in-business-central-part-5-creating-agent-from-code/
    title: Agents in Business Central – part 5 – Creating agent from code
    date: "2026-02-23"
    commit: null
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/codeunit/4321
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
post_id: "1272"
source_id: bertverbeek-nl
source_name: Discover MS BC - Bert Verbeek
url: https://www.bertverbeek.nl/blog/2026/02/23/agents-in-business-central-part-5-creating-agent-from-code/
published_at: "2026-02-23T09:00:00.000Z"
author: Bert Verbeek
full_text: false
words: 640
quotes: []
code_objects_mentioned:
  - enum Copilot Capability
  - codeunit Agent
  - interface IAgentFactory
  - interface IAgentMetadata
  - interface IAgentExperimental
  - interface IAgentTaskExecution
systems:
  - copilot
  - development
versions_mentioned: []
preview:
  embeddable: true
  frame_url: https://www.bertverbeek.nl/blog/2026/02/23/agents-in-business-central-part-5-creating-agent-from-code/embed/
  image: https://www.bertverbeek.nl/wp-content/uploads/2026/02/d365businesscentral_512x512.png
  image_alt: null
  image_w: null
  image_h: null
  site_name: Discover Microsoft Business Central - The wonderful world of Business Central
  favicon: https://www.bertverbeek.nl/wp-content/uploads/2026/02/d365businesscentral_256x256.png
  probed_at: "2026-10-07T11:50:32.530Z"
---

# Agents in Business Central – part 5 – Creating agent from code

[Read the post](https://www.bertverbeek.nl/blog/2026/02/23/agents-in-business-central-part-5-creating-agent-from-code/) · Discover MS BC - Bert Verbeek (Bert Verbeek) · 2026-02-23 · 640 words · tier community · reviewed (checked by Opus)

> 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.

## 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"](../../objects/codeunit/4321.md)
- 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.
