Skill Configuration

Overview

A native skill can expose configuration options that an administrator sets when they add the skill to an agent. The same skill can then behave differently on different agents. For most cases you declare configuration the same way you would on a block, using Rock field-type attributes, and the base class handles the editing UI for you. When you need a richer editing experience you can provide a custom Obsidian control.

Declaring Configuration

Declare each option as a Rock field-type attribute on the skill class, following the same conventions used for blocks: declare them vertically, assign properties rather than using constructor arguments, and define the keys as constants in a nested ConfigurationKey class.

[BooleanField(
    "Require Approval",
    Description = "When enabled, new items created by this skill must be approved before they take effect.",
    DefaultBooleanValue = true,
    Key = ConfigurationKey.RequireApproval )]
[Description( "This skill provides functionality to manage prayer." )]
[AgentSkillGuid( "0EF2BBFD-52D9-441B-9BE5-F4C5D2B42ED0" )]
[EntityTypeGuid( "6033D65E-C782-45BA-9A74-23F9B9353A27" )]
internal sealed partial class PrayerSkill : AgentSkillComponent
{
    private static class ConfigurationKey
    {
        public const string RequireApproval = "requireApproval";
    }
}

With field-type attributes alone, the base AgentSkillComponent automatically renders the editing UI, converts values for storage, and persists them. You do not need to write any UI code for this common case. File, image, background-check, and structured-content field types are not supported for skill configuration.

Reading Configuration Values

Inside a tool, read the values from the base-class ConfigurationValues property. This is a read-only dictionary of the values configured for the specific agent that the current request is running under.

var requireApproval = true;

if ( ConfigurationValues.TryGetValue( ConfigurationKey.RequireApproval, out var value ) )
{
    requireApproval = value.AsBoolean();
}

Custom Configuration UI

When field-type attributes are not enough (for example, you need a picker populated from live data), override the configuration methods on AgentSkillComponent and point them at your own Obsidian control: GetComponentDefinition returns the control URL and its options, while GetPublicConfiguration and GetPrivateConfiguration translate values between the UI and storage. ExecuteComponentRequest handles any dynamic requests the control makes back to the server. The built-in PrayerSkill uses this approach to present a prayer-category picker.