askill
sf-ai-agentforce

sf-ai-agentforceSafety --Repository

Standard Agentforce platform skill. Covers Setup UI-based agent building, topic/action configuration, PromptTemplate metadata, Einstein Models API, GenAiFunction/GenAiPlugin setup, and custom Lightning types. For Agent Script DSL development, use sf-ai-agentscript instead.

198 stars
4k downloads
Updated 3/19/2026

Package Files

Loading files...
SKILL.md

sf-ai-agentforce: Standard Agentforce Platform Development

Expert Agentforce developer specializing in the Setup UI / Agentforce Builder approach to agent development. Covers topic and action configuration, GenAiFunction/GenAiPlugin metadata, PromptTemplate authoring, Einstein Models API, and custom Lightning types.

Code-first alternative: For programmatic agent development using Agent Script DSL (.agent files), use sf-ai-agentscript instead. This skill covers the declarative, UI-driven approach.


Overview

Salesforce Agentforce enables organizations to build autonomous AI agents that handle customer interactions, automate tasks, and surface insights. This skill focuses on the standard platform approach:

  • Agentforce Builder (Setup UI) for visual agent configuration
  • GenAiFunction and GenAiPlugin metadata for registering actions
  • PromptTemplate metadata for reusable AI prompts
  • Einstein Models API (aiplatform.ModelsAPI) for native LLM access in Apex
  • Custom Lightning Types (LightningTypeBundle) for rich agent action UIs

Two Approaches to Agentforce

ApproachSkillWhen to Use
Setup UI / Agentforce Buildersf-ai-agentforce (this skill)Declarative agent config, point-and-click topics/actions
Agent Script DSLsf-ai-agentscriptCode-first .agent files, FSM architecture, version-controlled agents

Both approaches produce agents that run on the same Agentforce runtime. Choose based on team preference and complexity requirements.


Core Concepts

Topics

Topics are the primary organizational unit for an agent's capabilities. Each topic groups related actions and instructions around a specific domain.

  • Description: Tells the LLM planner when to route to this topic (must be specific and unambiguous)
  • Scope: Defines what the topic can and cannot do (helps the planner make routing decisions)
  • Instructions: Step-by-step guidance the agent follows when a topic is active
  • Actions: The operations (Flow, Apex, Prompt Template) the agent can invoke within this topic

In the Agentforce Builder, topics are configured via Setup → Agentforce → Agents → [Agent] → Topics.

Actions

Actions are the executable operations an agent can perform. Each action wraps an underlying invocation target:

Target TypeDescriptionRegistered Via
FlowInvokes an Autolaunched FlowGenAiFunction with invocationTargetType: flow
ApexInvokes an @InvocableMethodGenAiFunction with invocationTargetType: apex
Prompt TemplateInvokes a PromptTemplateGenAiFunction with invocationTargetType: prompt
Standard ActionBuilt-in platform actions (send email, create record)Pre-registered by Salesforce

Instructions

Instructions guide the agent's behavior within a topic. They are natural language directives that tell the LLM:

  • What steps to follow
  • When to invoke specific actions
  • How to handle edge cases and errors
  • When to escalate to a human agent

Agent Builder Workflow

Step-by-Step: Creating an Agent via Setup UI

1. Navigate to Agentforce Builder

Setup → Agentforce → Agents → New Agent

2. Choose Agent Type

  • Service Agent — Customer-facing support and service
  • Employee Agent — Internal productivity and automation

3. Add Topics For each capability area:

  • Provide a clear Name and Description
  • Write Instructions that guide the agent's reasoning
  • Add a Scope statement (what's in/out of bounds)

4. Configure Actions per Topic Assign actions to each topic. Actions can target:

  • Autolaunched Flows (most common)
  • Apex InvocableMethods (via GenAiFunction)
  • Prompt Templates (for LLM-generated content)
  • Standard platform actions

5. Set Action Inputs & Outputs For each action:

  • Define inputs the agent collects from the user (slot filling)
  • Define outputs the agent uses in its response
  • Mark which outputs are displayable to the user

6. Configure Agent-Level Settings

  • System Instructions: Global persona and behavior guidelines
  • Default Agent User: The running user context for the agent
  • Welcome Message: Initial greeting
  • Error Message: Fallback when something goes wrong

7. Preview & Test

# Preview in Agentforce Builder (uses standard org auth)
sf agent preview --api-name MyAgent --target-org MyOrg

8. Publish

sf agent publish authoring-bundle --api-name MyAgent --target-org MyOrg

# Publish (skip metadata retrieve for CI/CD pipelines, v2.122.6+)
sf agent publish authoring-bundle --api-name MyAgent --skip-retrieve --target-org MyOrg

CLI Agent Lifecycle

Manage agent state via CLI (requires agent to be published first):

CommandPurpose
sf agent activate --api-name X --target-org Y --jsonActivate a published agent
sf agent deactivate --api-name X --target-org Y --jsonDeactivate an active agent

Note: sf agent create --spec <file> exists but is NOT recommended — agents created this way don't use Agent Script and are less flexible. Use the authoring-bundle workflow instead.

Full lifecycle: Validate → Deploy → Publish → Activate → (Deactivate → Re-publish → Re-activate)

Cross-references: sf-deploy for deployment orchestration, sf-ai-agentscript for Agent Script development.

Agent Spec Generation

Generate an agent spec YAML with sf agent generate agent-spec. Key flags:

  • --type customer|internal — Agent type
  • --role, --company-name, --company-description — Core identity
  • --tone formal|casual|neutral — Conversational style
  • --full-interview — Interactive prompt for all properties
  • --spec <existing.yaml> — Iterative refinement of an existing spec

Full flag reference: See references/cli-commands.md for the complete generate agent-spec workflow with all 15+ flags.


GenAiFunction & GenAiPlugin Metadata

GenAiFunction

A GenAiFunction registers a single action that an Agentforce agent can invoke. It wraps an underlying Flow, Apex method, or Prompt Template.

Metadata XML Structure:

<?xml version="1.0" encoding="UTF-8"?>
<GenAiFunction xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Look Up Order Status</masterLabel>
    <developerName>Lookup_Order_Status</developerName>
    <description>Retrieves the current status of a customer order</description>

    <!-- Target: the Flow, Apex, or Prompt to invoke -->
    <invocationTarget>Get_Order_Status_Flow</invocationTarget>
    <invocationTargetType>flow</invocationTargetType>

    <!-- Capability: tells the LLM planner WHEN to use this action -->
    <capability>
        Look up the current status of a customer's order when they
        ask about shipping, delivery, or order tracking.
    </capability>

    <!-- Inputs: what the agent collects from the user -->
    <genAiFunctionInputs>
        <developerName>orderNumber</developerName>
        <description>The customer's order number</description>
        <dataType>Text</dataType>
        <isRequired>true</isRequired>
    </genAiFunctionInputs>

    <!-- Outputs: what the action returns -->
    <genAiFunctionOutputs>
        <developerName>orderStatus</developerName>
        <description>Current status of the order</description>
        <dataType>Text</dataType>
        <isRequired>true</isRequired>
    </genAiFunctionOutputs>
</GenAiFunction>

File Location:

force-app/main/default/genAiFunctions/Lookup_Order_Status.genAiFunction-meta.xml

Invocation Target Types

invocationTargetTypeTarget ValueNotes
flowFlow API nameFlow must be Active
apexApex class nameClass must have @InvocableMethod
promptPromptTemplate API nameTemplate must be Active

GenAiPlugin

A GenAiPlugin groups multiple GenAiFunction entries into a logical unit. This is useful for organizing related actions.

<?xml version="1.0" encoding="UTF-8"?>
<GenAiPlugin xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Order Management Plugin</masterLabel>
    <developerName>Order_Management_Plugin</developerName>
    <description>Actions for managing customer orders</description>

    <genAiFunctions>
        <functionName>Lookup_Order_Status</functionName>
    </genAiFunctions>
    <genAiFunctions>
        <functionName>Cancel_Order</functionName>
    </genAiFunctions>
    <genAiFunctions>
        <functionName>Return_Order</functionName>
    </genAiFunctions>
</GenAiPlugin>

File Location:

force-app/main/default/genAiPlugins/Order_Management_Plugin.genAiPlugin-meta.xml

Deployment Order

  1. Deploy the underlying Flow / Apex / PromptTemplate first
  2. Deploy GenAiFunction metadata (references the targets)
  3. Deploy GenAiPlugin metadata (references the functions)
  4. Publish the Agent (references the plugin/functions via topics)
# Step 1: Deploy targets
sf project deploy start -m "Flow:Get_Order_Status_Flow" --target-org MyOrg

# Step 2: Deploy GenAiFunction
sf project deploy start -m "GenAiFunction:Lookup_Order_Status" --target-org MyOrg

# Step 3: Deploy GenAiPlugin (optional grouping)
sf project deploy start -m "GenAiPlugin:Order_Management_Plugin" --target-org MyOrg

# Step 4: Publish agent
sf agent publish authoring-bundle --api-name MyAgent --target-org MyOrg

PromptTemplate Configuration

PromptTemplate is the metadata type for creating reusable AI prompts. Templates can be invoked by Agentforce agents (via GenAiFunction), Einstein Prompt Builder, Apex code, and Flows.

Template Types: flexPrompt | salesGeneration | fieldCompletion | recordSummary

Variable Types: freeText (runtime input) | recordField (SObject field binding) | relatedList (child records) | resource (Static Resource)

Key Integration Points:

  • Agent Action: Register a GenAiFunction with invocationTargetType: prompt
  • Apex: ConnectApi.EinsteinLlm.generateMessagesForPromptTemplate()
  • Flow: Use the "Prompt Template" action element

Full reference: See references/prompt-templates.md for complete metadata structure, variable types, examples, Data Cloud grounding, and best practices.


Models API

The Einstein Models API (aiplatform.ModelsAPI) enables native LLM access from Apex without external HTTP callouts. Use it for custom AI logic beyond what Agentforce topics/actions provide.

Available Models:

  • sfdc_ai__DefaultOpenAIGPT4OmniMini — Cost-effective general tasks
  • sfdc_ai__DefaultOpenAIGPT4Omni — Complex reasoning
  • sfdc_ai__DefaultAnthropic — Nuanced understanding
  • sfdc_ai__DefaultGoogleGemini — Multimodal tasks

Key Patterns:

  • Queueable for single-record async AI processing
  • Batch for bulk processing (scope size 10–20)
  • Platform Events for notifying completion to LWC/Flow

Prerequisites: Einstein Generative AI enabled, API v61.0+, Einstein Generative AI User permission set assigned.

Full reference: See references/models-api.md for complete Apex examples, Queueable/Batch patterns, Chatter integration, and governor limit guidance.


Custom Lightning Types

Custom Lightning Types (LightningTypeBundle) define structured data types with custom UI components for agent action inputs and outputs. When an agent action needs a rich input form or a formatted output display, create a custom type with:

  • schema.json — JSON Schema data structure definition
  • editor.json — Custom input collection UI (lightning components)
  • renderer.json — Custom output display UI (lightning components)

Requirements: API v64.0+ (Fall '25), Enhanced Chat V2 enabled in Service Cloud.

File Structure:

force-app/main/default/lightningTypeBundles/OrderDetails/
├── schema.json
├── editor.json
├── renderer.json
└── OrderDetails.lightningTypeBundle-meta.xml

Full reference: See references/custom-lightning-types.md for complete schema examples, editor/renderer configuration, and integration with GenAiFunction.


Orchestration Order

Prerequisite skills must run in this order:

sf-metadata → sf-apex → sf-flow → sf-ai-agentforce → sf-deploy

Why this order:

  1. sf-metadata — Custom objects/fields must exist before Apex/Flows reference them
  2. sf-apex — InvocableMethod classes must be deployed before Flows or GenAiFunctions reference them
  3. sf-flow — Flows must be active before GenAiFunctions can target them
  4. sf-ai-agentforce (this skill) — GenAiFunction/GenAiPlugin metadata and agent configuration
  5. sf-deploy — Final deployment and agent publishing

MANDATORY Delegations:

RequirementDelegate ToWhy
Flow creationUse the sf-flow skill110-point validation, proper XML
Apex creationUse the sf-apex skillInvocableMethod generation, 150-point scoring
DeploymentUse the sf-deploy skillCentralized deployment orchestration

Cross-Skill Integration

SkillPurposeWhen to Use
sf-ai-agentscriptAgent Script DSL (code-first)Writing .agent files with FSM architecture
sf-ai-agentforce-testingAgent testingTest execution, coverage analysis, agentic fix loops
sf-flowFlow actionsCreating Autolaunched Flows for agent actions
sf-apexApex actionsWriting InvocableMethod classes for agent actions
sf-deployDeploymentPublishing agents, deploying metadata
sf-metadataObject/field setupCreating SObjects and fields that actions reference
sf-integrationExternal APIsNamed Credentials, External Services for agent callouts

Integration Patterns

DirectionPatternNotes
Agent → FlowGenAiFunction targets FlowMost common action pattern
Agent → ApexGenAiFunction targets InvocableMethodFor complex business logic
Agent → PromptGenAiFunction targets PromptTemplateFor AI-generated content
Agent → Custom TypeGenAiFunction uses LightningTypeBundleRich input/output UIs
Agent → External APIFlow/Apex wraps Named Credential calloutVia sf-integration skill

Key Insights

InsightIssueFix
GenAiFunction requires active targetDeploying GenAiFunction before its Flow/Apex targetDeploy targets first, then GenAiFunction
PromptTemplate field bindings{!variableName} must match variable developerName exactlyCheck spelling and case sensitivity
Custom Lightning Types require v64.0+Bundle won't deploy on older API versionsSet <version>64.0</version> or higher in package.xml
GenAiPlugin groups functionsIndividual GenAiFunctions must exist before the pluginDeploy GenAiFunctions before GenAiPlugin
Capability text is criticalVague capability descriptions cause poor routingWrite specific, scenario-based capability text
Enhanced Chat V2 for custom typesCustom type UI won't render without itEnable Enhanced Chat V2 in Setup → Chat Settings
Models API needs async contextSynchronous calls in triggers will timeoutUse Queueable with Database.AllowsCallouts
Input/output names must matchGenAiFunction input names must match Flow variable API namesVerify exact name match (case-sensitive)
Validation before publishSkipping validation causes late-stage failuresAlways run sf agent validate authoring-bundle first
Data type mappingGenAiFunction dataType must align with target parameter typesUse Text, Number, Boolean, Date as appropriate

Scoring System (100 Points)

Categories

CategoryPointsKey Criteria
Agent Configuration20System instructions, welcome/error messages, agent user set
Topic & Action Design25Clear descriptions, proper scope, logical routing, capability text
Metadata Quality20Valid GenAiFunction/GenAiPlugin XML, correct target types, input/output definitions
Integration Patterns15Proper orchestration order, dependency management, cross-skill delegation
PromptTemplate Usage10Variable bindings correct, template types appropriate, prompts well-structured
Deployment Readiness10Validation passes, dependencies deployed first, package.xml correct

Thresholds

ScoreRatingAction
90–100ExcellentDeploy with confidence
80–89Very GoodMinor improvements suggested
70–79GoodReview before deploy
60–69Needs WorkAddress issues before deploy
< 60CriticalBlock deployment

Validation Report Format

Score: 87/100 ⭐⭐⭐⭐ Very Good
├─ Agent Configuration:     18/20 (90%)
├─ Topic & Action Design:   22/25 (88%)
├─ Metadata Quality:        17/20 (85%)
├─ Integration Patterns:    13/15 (87%)
├─ PromptTemplate Usage:     9/10 (90%)
└─ Deployment Readiness:     8/10 (80%)

Issues:
⚠️ [Metadata] GenAiFunction "Cancel_Order" missing output definition
⚠️ [Integration] Flow "Get_Order_Status" not yet deployed to org
✓ All PromptTemplate variable bindings valid
✓ GenAiPlugin references resolve correctly

Document Map

Tier 2: Detailed References

DocumentDescriptionRead When
references/cli-commands.mdCLI command reference for agent lifecycle, generation, and publishingUsing sf agent commands
references/prompt-templates.mdComplete PromptTemplate metadata, variable types, Data Cloud groundingAuthoring reusable AI prompts
references/models-api.mdaiplatform.ModelsAPI Apex patterns, Queueable/Batch integrationBuilding custom AI logic in Apex
references/custom-lightning-types.mdLightningTypeBundle schema/editor/renderer configurationCreating rich action input/output UIs

Cross-Skill References

NeedSkill
Agent Script DSL developmentsf-ai-agentscript
Agent testing & coveragesf-ai-agentforce-testing
Flow creation for actionssf-flow
Apex InvocableMethod classessf-apex
Metadata deploymentsf-deploy

Version History

VersionDateChanges
2.0.02026-02-07Complete rewrite. Skill refocused on standard Agentforce platform (Setup UI, GenAiFunction/GenAiPlugin, PromptTemplate, Models API, Custom Lightning Types). Agent Script DSL content moved to sf-ai-agentscript.

Sources & Acknowledgments

SourceContribution
Salesforce Agentforce DocumentationOfficial platform reference
Salesforce DiariesModels API patterns, Custom Lightning Types guide
trailheadapps/agent-script-recipesOfficial Salesforce examples
Jag ValaiyapathySkill authoring, scoring system, orchestration design

License

MIT License. See LICENSE file in sf-ai-agentforce folder. Copyright (c) 2024–2026 Jag Valaiyapathy

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

AI review pending.

Metadata

Licenseunknown
Version-
Updated3/19/2026
PublisherJaganpro

Tags

apici-cddatabasegithubgithub-actionsllmpromptingsecuritytesting