<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mac Nosek</title>
    <description>The latest articles on DEV Community by Mac Nosek (@modernstackmac).</description>
    <link>https://dev.to/modernstackmac</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4215478%2Ff1a9b92e-d872-4182-badd-8e99d4c305b8.png</url>
      <title>DEV Community: Mac Nosek</title>
      <link>https://dev.to/modernstackmac</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/modernstackmac"/>
    <language>en</language>
    <item>
      <title>Data 360 vs a Data Warehouse Sync: Which Does Your Salesforce Org Need?</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Thu, 29 Oct 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/data-360-vs-a-data-warehouse-sync-which-does-your-salesforce-org-need-1l7b</link>
      <guid>https://dev.to/modernstackmac/data-360-vs-a-data-warehouse-sync-which-does-your-salesforce-org-need-1l7b</guid>
      <description>&lt;p&gt;A lot of companies asking about Data 360 already have a data warehouse: Snowflake, Databricks, BigQuery or Redshift, with a team that runs it. The fair question is whether Salesforce needs its own data platform on top of that, or whether a sync from the warehouse is enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; if the warehouse already knows who each customer is and Salesforce only needs a few fields or scores on the record, sync them or use zero copy and skip the rest. Data 360 earns its cost when you need identity resolution, segments or agent grounding inside Salesforce, things a sync doesn't give you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Warehouse Sync Does Well
&lt;/h2&gt;

&lt;p&gt;A sync, usually called reverse ETL, pushes data from the warehouse into Salesforce fields on a schedule: a lifetime value score on the Account, a churn flag on the Contact, product usage on the Opportunity.&lt;/p&gt;

&lt;p&gt;It's the right call when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The warehouse already resolves identity.&lt;/strong&gt; Your data team has one customer ID and the matching logic to go with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Salesforce only needs to display it.&lt;/strong&gt; Reps need to see a number or a flag on the record, not build segments from it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The volume is modest.&lt;/strong&gt; A handful of fields on a few objects, refreshed daily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your data team owns the logic.&lt;/strong&gt; Calculations live where your analysts already work and test them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's cheap, it's simple, and the people who own the data keep owning it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Data 360 Earns Its Cost
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Identity resolution inside Salesforce.&lt;/strong&gt; When the same person exists as several Contacts, a Lead and a record in another system, Data 360 links them into one profile using match rules you control. On a &lt;a href="https://modernstacksystems.com/work/data-360-contact-360/" rel="noopener noreferrer"&gt;recent Contact 360 build&lt;/a&gt;, the master data system's IDs drove the matching, with email as a tightened fallback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Segments and activation.&lt;/strong&gt; If marketing builds audiences from combined CRM, product and engagement data and sends them to campaigns, that's Data 360's core job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent grounding.&lt;/strong&gt; Agentforce can ground on the unified profile and on unstructured content like Knowledge articles. If agents are on the roadmap, the data model you build now is the one they'll read.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculated insights next to the record.&lt;/strong&gt; Metrics computed across sources and shown in Sales or Service Cloud, without writing them back into fields on every object.&lt;/p&gt;

&lt;h2&gt;
  
  
  Zero Copy Changes the Math
&lt;/h2&gt;

&lt;p&gt;Data 360 doesn't have to copy everything. With zero copy federation, it can query tables that stay in Snowflake, Databricks, BigQuery or Redshift. Where you do need data inside Data 360, the warehouse connectors bring it in directly. On the Contact 360 project, meeting notes and attendee data came in through the Databricks connector, set up and tested in a sandbox first.&lt;/p&gt;

&lt;p&gt;That means the choice isn't always all or nothing. A common shape is to keep analytics and heavy transforms in the warehouse, federate the tables Salesforce needs, and use Data 360 only for identity, segments and grounding.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Cost Trap to Avoid
&lt;/h2&gt;

&lt;p&gt;Data 360 bills on consumption, so the biggest cost mistake is ingesting everything because the diagram looks thorough. Every stream you add is another refresh to pay for and maintain.&lt;/p&gt;

&lt;p&gt;The rule I use: if a record already lives in Salesforce and the page can query it, don't ingest it just to read it back. Ingest what identity resolution needs, federate what you can, and read the rest live.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Decide
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Does the warehouse already resolve each customer to one ID?&lt;/li&gt;
&lt;li&gt;Does Salesforce need to show the data, or build segments and decisions from it?&lt;/li&gt;
&lt;li&gt;Will agents need to ground on this data?&lt;/li&gt;
&lt;li&gt;Who should own the matching logic, your data team or your Salesforce team?&lt;/li&gt;
&lt;li&gt;Which tables could stay in the warehouse and be federated?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the warehouse resolves identity and Salesforce only needs to display a few values, start with a sync. If you need one profile, segments or agent grounding inside Salesforce, that's Data 360.&lt;/p&gt;

&lt;p&gt;Want a second opinion on your setup? &lt;a href="https://calendly.com/mac-nosek/30min" rel="noopener noreferrer"&gt;Book a call&lt;/a&gt;. More on how I run these projects on the &lt;a href="https://modernstacksystems.com/data-cloud/" rel="noopener noreferrer"&gt;Data Cloud consulting&lt;/a&gt; page.&lt;/p&gt;

</description>
      <category>datacloud</category>
      <category>data360</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Hiring a Custom MCP Server Developer: How to Scope the Project</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Wed, 28 Oct 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/hiring-a-custom-mcp-server-developer-how-to-scope-the-project-4ejk</link>
      <guid>https://dev.to/modernstackmac/hiring-a-custom-mcp-server-developer-how-to-scope-the-project-4ejk</guid>
      <description>&lt;p&gt;Most people who ask me about a custom MCP server start with the wrong spec. They want every endpoint of their API exposed to the agent. That's the fastest way to get an agent that picks the wrong tool, burns context and can't be trusted with write access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; a good MCP server exposes the handful of tools your agents actually need, scoped to your data and permissions. Before you hire anyone, be able to say which systems the agent has to reach, what it should do there, who it acts as, and where the server will run. Those four answers decide most of the timeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  What You're Actually Buying
&lt;/h2&gt;

&lt;p&gt;An MCP server is a translation layer. On one side is your system: Salesforce, an internal API, a database, a SaaS tool. On the other is any client that speaks the Model Context Protocol: Claude, Agentforce, or one of the growing list of agent platforms. The server decides what the agent can see and do.&lt;/p&gt;

&lt;p&gt;So the deliverable isn't really code that calls an API. It's a set of decisions about which actions exist, what they return, and what the agent is never allowed to touch. The code is the easy part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools, Not Endpoints
&lt;/h2&gt;

&lt;p&gt;The biggest difference between a server that works in a demo and one that works in production is tool design.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fewer, task-shaped tools.&lt;/strong&gt;"Find open cases for this account" beats exposing generic query, describe and retrieve calls and hoping the model strings them together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clear names and descriptions.&lt;/strong&gt; The model picks tools by reading them. Vague names mean wrong picks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Small, predictable responses.&lt;/strong&gt; Return the fields the agent needs, not the whole record. Big payloads crowd out the rest of the conversation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Errors the agent can act on.&lt;/strong&gt;"No account found with that name, try the account number" gets a retry. A raw stack trace gets a hallucination.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If someone quotes you a server by counting endpoints, ask how they decide what not to expose.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Drives the Timeline
&lt;/h2&gt;

&lt;p&gt;On my projects these are the things that move the estimate, roughly in order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Number of systems.&lt;/strong&gt; One system is the simple case. Each additional system adds its own auth, data model and failure modes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read only or read and write.&lt;/strong&gt; Writes need confirmation patterns, validation and audit logging. Read-only servers ship much faster.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auth model.&lt;/strong&gt; An API key for one internal user is quick. OAuth so each person acts as themselves, with their own permissions, takes real design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where it runs.&lt;/strong&gt; Local next to Claude Desktop or Claude Code is the fastest. A hosted remote server for a whole team adds deployment, monitoring and access control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tenancy and compliance.&lt;/strong&gt; Multi-tenant or regulated deployments add isolation, a security review and more testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For reference, a single-system server is typically 1 to 2 weeks, multi-system with auth and remote deployment 2 to 4, and multi-tenant or regulated deployments 4 to 8.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security Questions to Settle Early
&lt;/h2&gt;

&lt;p&gt;Agents with write access to production data need the same scrutiny as any integration user, plus a few things specific to AI:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who does the agent act as?&lt;/strong&gt; A shared service account is simple but flattens permissions. Per-user OAuth keeps your existing sharing model intact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Least privilege.&lt;/strong&gt; The server's credentials should only reach what its tools need.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-only modes.&lt;/strong&gt; Useful for rollout. Let people trust it on reads before you turn on writes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit logs on every write.&lt;/strong&gt; You want to know what the agent changed, when and for whom.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt injection.&lt;/strong&gt; Anything the server returns, like a case description or an email body, can carry instructions. Tools that write should never act on text they just read without a check.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Questions to Ask Before You Hire
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Which tools would you build for our use case, and which parts of the API would you leave out?&lt;/li&gt;
&lt;li&gt;How do you handle auth, and can users act as themselves?&lt;/li&gt;
&lt;li&gt;How do you test it? Against our real systems or mocks?&lt;/li&gt;
&lt;li&gt;What happens when the MCP spec changes?&lt;/li&gt;
&lt;li&gt;Who maintains it after launch?&lt;/li&gt;
&lt;li&gt;Does it work with more than one AI platform, or only one vendor's client?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last one matters more than it looks. MCP's whole value is that you build the server once and any compatible client can use it. A build that only works in one tool gives that up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build It Yourself or Hire It Out
&lt;/h2&gt;

&lt;p&gt;If you have engineers who know the system well and the server is read-only for internal use, build it yourself. The SDKs are good and a first server is a reasonable weekend project.&lt;/p&gt;

&lt;p&gt;Hire it out when the server writes to production systems, spans more than one system, needs per-user auth, or has to be hosted for a team. That's where the tool design and security decisions take experience, and where mistakes are expensive.&lt;/p&gt;

&lt;p&gt;If you want a second opinion on how yours should be scoped, &lt;a href="https://calendly.com/mac-nosek/30min" rel="noopener noreferrer"&gt;book a call&lt;/a&gt;. More on how I build and deliver them on the &lt;a href="https://modernstacksystems.com/mcp-development/" rel="noopener noreferrer"&gt;MCP development page&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>aiagents</category>
      <category>consulting</category>
    </item>
    <item>
      <title>Data 360 Identity Resolution with Informatica MDM and Databricks: A Lean Architecture</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Wed, 28 Oct 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/data-360-identity-resolution-with-informatica-mdm-and-databricks-a-lean-architecture-4734</link>
      <guid>https://dev.to/modernstackmac/data-360-identity-resolution-with-informatica-mdm-and-databricks-a-lean-architecture-4734</guid>
      <description>&lt;p&gt;I'm wrapping up a 6-week Data 360 project for a global financial data company. The goal was simple to say and hard to build: one view of each person on the Salesforce Contact page, even when that person exists as three Contacts, a Lead and a record in the master data system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; ingest only what identity resolution needs, key identity on the MDM ID with a tightened email rule as the fallback, bring warehouse data in from Databricks, and keep reading CRM records live from Salesforce. Use the unified profile to decide who belongs together, not as the source of field values.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Salesforce CRM&lt;/strong&gt; with years of duplicate Contacts, plus Leads for the same people&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Informatica MDM&lt;/strong&gt; as the master for who a person is. Every Contact carries an MDM ID, at least in theory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Databricks&lt;/strong&gt; as the enterprise data warehouse, holding meeting notes and attendee data the sales team wanted on the Contact page&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data 360&lt;/strong&gt; , already licensed and shared with the marketing team&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lean Model vs. Comprehensive Model
&lt;/h2&gt;

&lt;p&gt;The first plan ingested almost everything: opportunities, activities and the rest of the CRM objects, all mapped into the data model. It looks thorough on a diagram. In practice it means more streams to maintain, more credits every refresh, and a copy of CRM data that's always a little behind.&lt;/p&gt;

&lt;p&gt;We pivoted to a lean model. Data 360 ingests Account, Contact, Lead and the Contact Point objects, which is what identity resolution actually needs. Opportunities, activities and other CRM records are read live from Salesforce on the page. The client confirmed the base objects as the plan of record.&lt;/p&gt;

&lt;p&gt;The rule I'd give anyone starting out: if a record already lives in Salesforce and the page can query it, don't ingest it just to read it back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting the MDM ID Into Identity Resolution
&lt;/h2&gt;

&lt;p&gt;Identity resolution doesn't match on a custom field on Contact. It matches on the data model, so the MDM ID has to become a Party Identification record.&lt;/p&gt;

&lt;p&gt;A batch data transform reads each Contact's MDM ID and writes one Party Identification row per Contact, with the identification name set to MDM_ID. It filters out three kinds of bad data before they can cause false merges:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blank MDM IDs&lt;/li&gt;
&lt;li&gt;Placeholder IDs the source system uses when it doesn't have a real one&lt;/li&gt;
&lt;li&gt;Any ID shared by more than 10 Contacts, which is almost always a data problem, not one person&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The transform runs daily, scheduled before the identity resolution run, so new MDM IDs are picked up the next day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Match Rules
&lt;/h2&gt;

&lt;p&gt;The ruleset ended up with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MDM ID:&lt;/strong&gt; exact match on Party Identification where the identification name is MDM_ID, with match on blank turned off&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lead to Contact:&lt;/strong&gt; keeps a converted Lead linked to its Contact&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email:&lt;/strong&gt; exact normalized email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Email alone is the weakest rule in most designs, and shared mailboxes are the reason. Two analysts on the same team inbox merge into one person on email alone. My recommendation is to tighten it with last name, and to keep role-based addresses like info@ and research@ out of matching entirely, using the same "shared by too many people" pattern as the MDM filter.&lt;/p&gt;

&lt;p&gt;Accounts aren't unified. The project was about people.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Shared Ruleset Problem
&lt;/h2&gt;

&lt;p&gt;Data 360 orgs often have one identity ruleset that marketing already depends on. Changing its match rules changes their unified profiles too.&lt;/p&gt;

&lt;p&gt;We added the MDM rule to the shared ruleset, because MDM rows only come from Contacts and can't create merges between marketing-only profiles. The plan is for marketing to sign off before the first run, with a separate ruleset on Individual as the fallback if they object. Get that conversation done before you touch a shared ruleset, not after.&lt;/p&gt;

&lt;h2&gt;
  
  
  Databricks as a Source
&lt;/h2&gt;

&lt;p&gt;The meeting notes and attendee tables live in Databricks. We set up the Databricks connector in Data 360 with identity provider based authentication and brought in the notes extract and attendee tables, set up and tested in a UAT sandbox first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live Values, Not Reconciled Ones
&lt;/h2&gt;

&lt;p&gt;This is the decision that kept the build small. The Contact page reads live Salesforce values. The unified profile is only used to find which Contacts and Leads belong to the same person, through the identity link records. Field values never come from the unified record.&lt;/p&gt;

&lt;p&gt;That means no custom reconciliation rules, no fight over which source wins for phone number, and no stale data on the page. If you're tempted to build reconciliation rules, check first whether anything actually reads the reconciled values.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd Tell Anyone Starting a Data 360 Project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Start lean. Ingest what identity resolution needs and read the rest live&lt;/li&gt;
&lt;li&gt;Put your master ID into Party Identification with a transform, and filter bad IDs before they merge people&lt;/li&gt;
&lt;li&gt;Never rely on email alone. Add a name and keep shared mailboxes out&lt;/li&gt;
&lt;li&gt;Record a baseline before the first identity run (how many Contacts have a valid MDM ID, how many were filtered) so you can show coverage improving&lt;/li&gt;
&lt;li&gt;If the ruleset is shared, get sign-off before the first run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're scoping Data 360 and want a second opinion on how lean your model can be, &lt;a href="https://calendly.com/mac-nosek/30min" rel="noopener noreferrer"&gt;book a call&lt;/a&gt;. More on how I run these projects on the &lt;a href="https://modernstacksystems.com/data-cloud/" rel="noopener noreferrer"&gt;Data Cloud consulting&lt;/a&gt; page.&lt;/p&gt;

</description>
      <category>datacloud</category>
      <category>data360</category>
      <category>identityresolution</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Salesforce MCP: Connecting Claude to Your Org in Practice</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Thu, 16 Apr 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/salesforce-mcp-connecting-claude-to-your-org-in-practice-2jof</link>
      <guid>https://dev.to/modernstackmac/salesforce-mcp-connecting-claude-to-your-org-in-practice-2jof</guid>
      <description>&lt;p&gt;I'll just start with what happened.&lt;/p&gt;

&lt;p&gt;I was debugging a data issue on a client's org. Normally that means: open the org in a browser, navigate to the record, check field values, open Developer Console, write SOQL, run it, copy results, paste into my notes, think about it, write another query, repeat. Probably 15 minutes of tab-switching before I even start solving the problem.&lt;/p&gt;

&lt;p&gt;With MCP connected, I described the issue to Claude, it queried the records directly, pulled the field values, checked the related records, and showed me the data flow. Same investigation, maybe 3 minutes. That's when MCP went from "interesting tool" to "I'm not going back."&lt;/p&gt;

&lt;h2&gt;
  
  
  What MCP Is
&lt;/h2&gt;

&lt;p&gt;MCP (Model Context Protocol) is an open protocol, originally from Anthropic, now under the Agentic AI Foundation (part of the Linux Foundation). It defines a standardized way for AI tools to connect to external systems. An MCP server exposes tools (functions the AI can call) and resources (data it can read). An MCP client (Claude Desktop, Claude Code, Cursor) connects to those servers and gives the AI access to their capabilities.&lt;/p&gt;

&lt;p&gt;For Salesforce, an MCP server translates Salesforce API operations into tools Claude can call. When I ask "what fields are on the Financial_Account__c object?" Claude doesn't guess. It calls the Describe endpoint on the actual org and gives me the live answer.&lt;/p&gt;

&lt;p&gt;MCP is not a Salesforce product (though Salesforce has announced native MCP client support in Agentforce, currently in pilot). It's a protocol layer that makes existing APIs accessible to AI tools.&lt;/p&gt;

&lt;p&gt;By early 2026, MCP had been adopted by OpenAI, Google, Microsoft, and Salesforce, and donated to the Agentic AI Foundation under the Linux Foundation. That kind of convergence on an infrastructure standard almost never happens. Investing in MCP-based integrations is a safe bet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;The Salesforce CLI team maintains an official MCP server at &lt;code&gt;salesforcecli/mcp&lt;/code&gt; on GitHub. That's the one I use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install the server.&lt;/strong&gt; It runs as a Node.js process. Clone the repo, install deps, configure the connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authenticate.&lt;/strong&gt; It uses your existing Salesforce CLI auth. If you've already run &lt;code&gt;sf org login web&lt;/code&gt; for your target org, the MCP server picks up that auth context. No separate credential setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Point your MCP client to it.&lt;/strong&gt; In Claude Code or Claude Desktop, add the server in your MCP config. Once connected, Claude sees the available tools and can invoke them during your conversation.&lt;/p&gt;

&lt;p&gt;Whole thing takes about 15 minutes if you're already familiar with the Salesforce CLI.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Actually Use It
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Schema exploration without opening Setup
&lt;/h3&gt;

&lt;p&gt;I work on a lot of client orgs. I don't have every object and field memorized. Instead of navigating to Object Manager and clicking through tabs, I just ask Claude what's on the object. It calls the Describe API and returns the field list with types, labels, and relationships.&lt;/p&gt;

&lt;p&gt;This comes up constantly with managed packages or FSC orgs where there are dozens of packaged objects you didn't build. "What custom fields are on FinServ__FinancialAccount__c?" Real answer. From the real org. In seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  SOQL that writes and runs itself
&lt;/h3&gt;

&lt;p&gt;I describe what data I need in plain English. Claude writes the SOQL, runs it, and returns the results. If something's off (wrong filter, missing relationship), I describe the fix and Claude adjusts and re-runs.&lt;/p&gt;

&lt;p&gt;This kills the loop of: write SOQL in Developer Console, copy the results, paste into chat, ask for analysis, get suggestions, go back to Dev Console. The AI sees the data directly. One conversation, not four tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Debugging with the actual records
&lt;/h3&gt;

&lt;p&gt;I mentioned this in the intro. When I'm troubleshooting, Claude can query the specific records involved, inspect field values, check related objects, and trace the data. Instead of me describing the problem in abstract terms ("there's an Account with a null field that should have been populated by the trigger"), the AI looks at the data and can tell me exactly what happened.&lt;/p&gt;

&lt;p&gt;For issues that depend on specific data states (a trigger that fires correctly for 99% of records but fails on one edge case), this saves a ton of time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding what's deployed
&lt;/h3&gt;

&lt;p&gt;"Show me all the triggers on the Opportunity object." "What Apex classes reference the Meeting_Note__c.Status__c field?" "How many active flows are there on Account?"&lt;/p&gt;

&lt;p&gt;Claude queries the Tooling API and compiles the info. For orgs with years of accumulated automation, this kind of quick audit is useful before making changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code generation that knows your schema
&lt;/h3&gt;

&lt;p&gt;When Claude generates Apex or LWC, it can reference your actual schema. Real field API names, real relationship names, real picklist values. Not placeholders you have to manually correct.&lt;/p&gt;

&lt;p&gt;I used to spend probably 10% of my time fixing generated code where field names didn't match the actual org. That's just gone now.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Workflow Shift
&lt;/h2&gt;

&lt;p&gt;Before MCP, my setup for client work was: org open in Chrome, VS Code, Developer Console or Workbench, and constant copy-paste between all of them. Context lived in my head.&lt;/p&gt;

&lt;p&gt;Now the AI has direct access to the org. I describe what I'm building, it pulls the context it needs, generates code against real metadata, and I deploy. The context-switching drops dramatically.&lt;/p&gt;

&lt;p&gt;Is it a 10x improvement? No. But across dozens of interactions per day, the time compounds. And the quality improvement (code that references the correct field names the first time) compounds even more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where This Is Heading
&lt;/h2&gt;

&lt;p&gt;Salesforce has MCP client support coming to Agentforce (in pilot now). The same MCP servers that connect Claude to my dev workflow could also connect Agentforce agents to external systems. An MCP server for your data warehouse or internal APIs becomes a universal integration layer that works with your dev tools and your production agents.&lt;/p&gt;

&lt;p&gt;That's the real play. The protocol is converging across the industry. Building MCP servers now gives you connectors that work with basically every AI tool and platform on the market.&lt;/p&gt;

&lt;p&gt;If you want help setting up MCP for your Salesforce dev workflow or building MCP-based integrations, &lt;a href="https://calendly.com/mac-nosek/30min" rel="noopener noreferrer"&gt;let's talk&lt;/a&gt;, or see how I approach &lt;a href="https://modernstacksystems.com/mcp-development/" rel="noopener noreferrer"&gt;custom MCP server development&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>claude</category>
      <category>salesforce</category>
      <category>developertools</category>
    </item>
    <item>
      <title>Agentforce vs. Building Your Own AI Agents: When to Use Which</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Tue, 07 Apr 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/agentforce-vs-building-your-own-ai-agents-when-to-use-which-3hgn</link>
      <guid>https://dev.to/modernstackmac/agentforce-vs-building-your-own-ai-agents-when-to-use-which-3hgn</guid>
      <description>&lt;p&gt;I build Agentforce agents and I build custom AI agents. Different clients, different problems, different tools. The question I get most is some version of: "which one should we use?"&lt;/p&gt;

&lt;p&gt;The answer comes down to three things: where your data lives, where your users work, and how much control you need. Let me walk through how I think about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Definitions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Agentforce&lt;/strong&gt; is Salesforce-native. Agents run inside the Salesforce ecosystem, access your org's data without custom integrations, and can be embedded in Service Console, Experience Cloud, or Slack. They inherit your sharing model and field-level security automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom agents&lt;/strong&gt; (what I build as custom AI development) run on LLMs like Claude or GPT, connect to your systems via API, and deploy to Slack, WhatsApp, or Telegram. They're not tied to any one platform. I define the skills, data connections, persona, and deployment target from scratch.&lt;/p&gt;

&lt;p&gt;Both use large language models under the hood. Both can execute tasks and interact conversationally. The difference is in the architecture and the trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agentforce Wins Here
&lt;/h2&gt;

&lt;p&gt;Agentforce is the shorter path when the use case is Salesforce-centric. If the data lives in your org and the people using the agent work inside Salesforce, don't overcomplicate it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service deflection&lt;/strong&gt; is Agentforce's home turf. An agent handling customer inquiries using Knowledge articles, case data, and account info. It lives in your Experience Cloud portal, creates cases, updates records, escalates to humans. All within the Salesforce security model. I've stood these up and they work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sales process support&lt;/strong&gt; is getting better fast, especially with the Spring '26 investment ("Agentforce Sales"). Agents that qualify leads, summarize account activity, or prep meeting briefs using CRM data. The data is already structured and accessible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compliance-sensitive workflows&lt;/strong&gt; are a big one. Agentforce inherits your org's sharing model, profiles, permission sets. If you need the agent to respect the same data access rules as your users, that's built in. With a custom agent, you're building that authorization layer from scratch. I cover this more in my RAG architecture post, but it's meaningful engineering effort.&lt;/p&gt;

&lt;p&gt;The pattern: if the question is "how do I make Salesforce smarter for people already inside Salesforce," Agentforce is the answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Custom Agents Win Here
&lt;/h2&gt;

&lt;p&gt;Custom agents make more sense when the use case extends beyond Salesforce, when the users don't live in Salesforce, or when you need the agent to pull from multiple systems in a single interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Slack-first teams.&lt;/strong&gt; I have clients where the field team opens Salesforce maybe once a week. Their world is Slack. Putting an agent inside Salesforce doesn't help those people. A custom agent in Slack that queries Salesforce, their ERP, and a data warehouse gives them what they need without changing how they work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-system orchestration.&lt;/strong&gt; Check inventory in the ERP, pull client data from Salesforce, look up shipping status from a third-party API, summarize it all in one response. Agentforce can call external APIs, but custom agents are built from the ground up for this kind of cross-system work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-Salesforce data as the primary source.&lt;/strong&gt; If most of what the agent needs lives in a data warehouse, a product database, or internal docs outside Salesforce, a custom agent with direct connections to those systems is more efficient than routing everything through Salesforce as a middleman.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Speed.&lt;/strong&gt; Custom agents go from concept to production in weeks with no dependency on Salesforce release cycles, org configuration, or license availability. If you want to test an AI agent concept fast, this is the faster path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Both. Sometimes the Answer is Both.
&lt;/h2&gt;

&lt;p&gt;Not a cop-out. I've seen this work well.&lt;/p&gt;

&lt;p&gt;Agentforce handles the Salesforce-native interactions: service deflection, internal record queries, sales process support. A custom agent in Slack handles the cross-functional stuff that doesn't fit in the Salesforce UI. Different users, different contexts, minimal overlap.&lt;/p&gt;

&lt;p&gt;Where it gets interesting: the custom Slack agent can write data back to Salesforce. A field rep asks the Slack agent a question, the agent pulls from multiple systems, and logs the interaction as a Task for audit purposes. The two agents aren't competing. They're serving different layers of the same ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Quick Decision Framework
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Agentforce if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Primary data source is Salesforce&lt;/li&gt;
&lt;li&gt;Users work inside Salesforce or Experience Cloud&lt;/li&gt;
&lt;li&gt;Sharing and security model matters&lt;/li&gt;
&lt;li&gt;You're invested in the Salesforce AI stack (Data Cloud, Einstein)&lt;/li&gt;
&lt;li&gt;Use case is service, sales, or CRM-centric internal ops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Custom agent if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Primary workspace is Slack, WhatsApp, or Telegram&lt;/li&gt;
&lt;li&gt;Agent needs data from multiple systems&lt;/li&gt;
&lt;li&gt;You need full control over the LLM, prompts, and behavior&lt;/li&gt;
&lt;li&gt;Speed to production matters more than platform alignment&lt;/li&gt;
&lt;li&gt;Use case doesn't require Salesforce record access at all&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Both if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Salesforce-heavy internal users AND Slack-heavy cross-functional teams&lt;/li&gt;
&lt;li&gt;Different user groups have fundamentally different tool preferences&lt;/li&gt;
&lt;li&gt;You need native CRM automation AND multi-system intelligence&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One More Thing
&lt;/h2&gt;

&lt;p&gt;The Salesforce ecosystem would like you to believe Agentforce is the answer to every AI question. It's not. It's a strong platform for CRM-centric use cases and it's getting better fast (Spring '26's Builder and Agent Script are real improvements). But most organizations I work with have workflows, data, and people that extend well beyond Salesforce.&lt;/p&gt;

&lt;p&gt;The best implementations I've delivered are the ones where someone took the time to map use cases to the right tool instead of defaulting to whatever the vendor rep pitched.&lt;/p&gt;

&lt;p&gt;Not sure where your use case lands? &lt;a href="https://calendly.com/mac-nosek/30min" rel="noopener noreferrer"&gt;Grab a call&lt;/a&gt; and I'll give you my honest take. You can also see how I deliver &lt;a href="https://modernstacksystems.com/agentforce/" rel="noopener noreferrer"&gt;Agentforce&lt;/a&gt; and &lt;a href="https://modernstacksystems.com/ai/" rel="noopener noreferrer"&gt;custom AI agents&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>agentforce</category>
      <category>aiagents</category>
      <category>openclaw</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Confluence Salesforce Integration: Syncing Articles to Knowledge with Data Cloud</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Wed, 08 Oct 2025 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/confluence-salesforce-integration-syncing-articles-to-knowledge-with-data-cloud-53k4</link>
      <guid>https://dev.to/modernstackmac/confluence-salesforce-integration-syncing-articles-to-knowledge-with-data-cloud-53k4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foia0llb69y52skxt7d3k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foia0llb69y52skxt7d3k.png" alt="Confluence to Salesforce Knowledge architecture diagram" width="800" height="958"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your organization uses Confluence as your internal knowledge base but wants to surface that content in Salesforce Knowledge for your support teams or AI agents, you're in luck. Data Cloud makes it possible to automatically sync Confluence articles into Salesforce Knowledge without manual copying or complex integrations.&lt;/p&gt;

&lt;p&gt;In this guide, I'll walk you through how to set up a real-time sync from Confluence to Salesforce Knowledge using Data Cloud's native connectors, data transforms, and a bit of Apex.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=WAWN8oLtAf8" rel="noopener noreferrer"&gt;Watch on YouTube&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Sync Confluence to Salesforce Knowledge?
&lt;/h2&gt;

&lt;p&gt;Many organizations maintain rich documentation in Confluence but need that same content accessible in Salesforce for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Support agents using Service Console&lt;/li&gt;
&lt;li&gt;Agentforce agents that need to reference company knowledge&lt;/li&gt;
&lt;li&gt;Customer-facing knowledge bases&lt;/li&gt;
&lt;li&gt;Unified search across all business systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rather than maintaining duplicate content in both systems, Data Cloud lets you create a single source of truth in Confluence that automatically flows into Salesforce.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture Overview
&lt;/h2&gt;

&lt;p&gt;The solution uses four main components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Cloud Connectors&lt;/strong&gt; -- Native Confluence integration to stream article data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Transform&lt;/strong&gt; -- Unified view combining pages and page content&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Cloud Triggered Flow&lt;/strong&gt; -- Fires when new articles are detected&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apex Queueable&lt;/strong&gt; -- Creates or updates Knowledge articles in draft state&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Configuration Steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Connect Confluence to Data Cloud
&lt;/h3&gt;

&lt;p&gt;Data Cloud includes a pre-built Confluence connector that makes setup straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to Data Cloud setup&lt;/li&gt;
&lt;li&gt;Select the Confluence connector&lt;/li&gt;
&lt;li&gt;Generate an API token from your Confluence instance&lt;/li&gt;
&lt;li&gt;Configure the connector with your Confluence URL and API token&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once connected, you'll have access to all your Confluence data in Data Cloud.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create Data Streams
&lt;/h3&gt;

&lt;p&gt;For this use case, you'll need two data streams:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pages Stream&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contains metadata about each Confluence page&lt;/li&gt;
&lt;li&gt;Includes title, page ID, URL, and timestamps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Page Contents Stream&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contains the actual body content of each page&lt;/li&gt;
&lt;li&gt;Includes HTML/storage format of the article&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When configuring your streams:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select only the fields you need (keeps processing efficient)&lt;/li&gt;
&lt;li&gt;Use custom formula fields if you need to transform data&lt;/li&gt;
&lt;li&gt;Rename API names to match your naming conventions&lt;/li&gt;
&lt;li&gt;Setup an &lt;strong&gt;incremental schedule&lt;/strong&gt; so only new or updated records sync (I recommend hourly)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Create a Data Transform
&lt;/h3&gt;

&lt;p&gt;Rather than working with two separate streams, create a Data Transform to unify them into a single table:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new Data Transform called "Knowledge Source Article"&lt;/li&gt;
&lt;li&gt;Pull in both data streams (Pages and Page Contents)&lt;/li&gt;
&lt;li&gt;Join them on ID and Page ID fields&lt;/li&gt;
&lt;li&gt;Select only the relevant fields: Page ID, Title, URL, Body content, and Timestamps&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This transform runs on the same schedule as your streams (hourly in my setup), creating a clean, unified view of your Confluence articles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Build the Data Cloud Triggered Flow
&lt;/h3&gt;

&lt;p&gt;Now create a Flow that fires whenever records are added or updated in your transform table:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new &lt;strong&gt;Data Cloud Triggered Flow&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Set the trigger to your Knowledge Source Article transform&lt;/li&gt;
&lt;li&gt;Configure it to fire on new or updated records&lt;/li&gt;
&lt;li&gt;Add an Apex action that calls your sync class&lt;/li&gt;
&lt;li&gt;Pass the page ID, title, and body content as parameters&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Flow acts as a trampoline, immediately queuing the work asynchronously so it doesn't block the Data Cloud pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Apex Processing Logic
&lt;/h3&gt;

&lt;p&gt;The Apex handles the actual Knowledge article creation or updates. Here's what it does:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For existing articles:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses &lt;code&gt;KbManagement.PublishingService.editOnlineArticle()&lt;/code&gt; to create a new draft version&lt;/li&gt;
&lt;li&gt;Updates the draft with the latest content from Confluence&lt;/li&gt;
&lt;li&gt;Leaves it in draft state for review&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For new articles:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a new Knowledge__kav record&lt;/li&gt;
&lt;li&gt;Sets language to 'en_US'&lt;/li&gt;
&lt;li&gt;Stores the Confluence Page ID for future matching&lt;/li&gt;
&lt;li&gt;Generates a URL-friendly slug&lt;/li&gt;
&lt;li&gt;Leaves in draft state for review&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 6: Backfill Existing Articles
&lt;/h3&gt;

&lt;p&gt;If you already have hundreds of Confluence articles, you'll want to backfill them rather than waiting for each to be updated. The solution includes a batchable Apex class that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queries your Data Transform for all existing records&lt;/li&gt;
&lt;li&gt;Checks which ones don't yet exist in Knowledge&lt;/li&gt;
&lt;li&gt;Bulk inserts missing articles in batches&lt;/li&gt;
&lt;li&gt;Handles truncation for articles exceeding field limits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run this once during initial setup to populate your Knowledge base.&lt;/p&gt;

&lt;h2&gt;
  
  
  Apex Components
&lt;/h2&gt;

&lt;p&gt;Here's a high-level view of the key Apex components:&lt;/p&gt;

&lt;h3&gt;
  
  
  ConfluenceKnowledgeSync -- Invocable Method
&lt;/h3&gt;

&lt;p&gt;Called by the Flow, this class queues the actual processing asynchronously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;without&lt;/span&gt; &lt;span class="n"&gt;sharing&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ConfluenceKnowledgeSync&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;bodyHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@InvocableMethod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Sync Confluence Articles to Knowledge'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enqueueJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;responses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'QUEUED'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Enqueued for processing'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;responses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;responses&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ConfluenceKnowledgeProcessor -- Queueable
&lt;/h3&gt;

&lt;p&gt;The queueable that does the actual Knowledge article creation and updates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;without&lt;/span&gt; &lt;span class="n"&gt;sharing&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Queueable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SyncRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;bodyHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;QueueableContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Processing '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' sync requests'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nf"&gt;processSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nc"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Successfully synced pageId: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nc"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Failed to sync pageId: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;
                    &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' - '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nc"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;saveLog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;processSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Knowledge__kav&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;existingArticles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="no"&gt;SELECT&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;KnowledgeArticleId&lt;/span&gt;
            &lt;span class="no"&gt;FROM&lt;/span&gt; &lt;span class="nc"&gt;Knowledge__kav&lt;/span&gt;
            &lt;span class="no"&gt;WHERE&lt;/span&gt; &lt;span class="nc"&gt;Confluence_Page_Id__c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;
            &lt;span class="no"&gt;AND&lt;/span&gt; &lt;span class="nc"&gt;IsLatestVersion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
            &lt;span class="no"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;existingArticles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;draftArticleId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;KbManagement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PublishingService&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;editOnlineArticle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;existingArticles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;KnowledgeArticleId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nc"&gt;Knowledge__kav&lt;/span&gt; &lt;span class="n"&gt;draftArticle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="no"&gt;SELECT&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="no"&gt;FROM&lt;/span&gt; &lt;span class="nc"&gt;Knowledge__kav&lt;/span&gt; &lt;span class="no"&gt;WHERE&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;draftArticleId&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;draftArticle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNotBlank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Confluence '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;draftArticle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Answer__c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bodyHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="n"&gt;draftArticle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;Knowledge&lt;/span&gt; &lt;span class="n"&gt;__kav&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Knowledge__&lt;/span&gt; &lt;span class="nf"&gt;kav&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNotBlank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Confluence '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Language&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'en_US'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Confluence_Page_Id__c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;UrlName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Answer__c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bodyHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;insert&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  InitialKnowledgeLoadQueueable -- Backfill
&lt;/h3&gt;

&lt;p&gt;One-time batch loader for existing Confluence articles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;with&lt;/span&gt; &lt;span class="n"&gt;sharing&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;InitialKnowledgeLoadQueueable&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Queueable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ArticleRecord&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;bodyHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ArticleRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;articlesToLoad&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;InitialKnowledgeLoadQueueable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ArticleRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;articlesToLoad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;articlesToLoad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;articlesToLoad&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
            &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ArticleRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;articlesToLoad&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;QueueableContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;syncBatch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
            &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ArticleRecord&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;articlesToLoad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
                &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SyncRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bodyHtml&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bodyHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;syncBatch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;syncBatch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enqueueJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ConfluenceKnowledgeProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;syncBatch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Seeing It In Action
&lt;/h2&gt;

&lt;p&gt;Once configured, the workflow is simple: create or update a Confluence page, wait for your scheduled sync (hourly in my case), and the article appears in Salesforce Knowledge as a draft. Your Knowledge admins can then review and publish it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Benefits
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Single Source of Truth&lt;/strong&gt; -- Content teams manage articles in Confluence, their familiar tool&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automatic Syncing&lt;/strong&gt; -- Updates in Confluence flow to Salesforce without manual work&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Draft State Protection&lt;/strong&gt; -- Articles arrive as drafts, giving admins a chance to review before publishing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalable&lt;/strong&gt; -- Handles hundreds or thousands of articles through batching&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Native Integration&lt;/strong&gt; -- Uses Data Cloud's built-in Confluence connector (no middleware required)&lt;/p&gt;

&lt;h2&gt;
  
  
  Considerations
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scheduling&lt;/strong&gt; -- Hourly syncs work well for most use cases, but adjust based on how quickly you need changes reflected&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Formatting&lt;/strong&gt; -- Confluence HTML may need cleanup depending on your Knowledge template. Consider adding transformation logic if needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Field Limits&lt;/strong&gt; -- Salesforce Knowledge fields have length limits (131,072 characters for rich text). The backfill class includes truncation logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permissions&lt;/strong&gt; -- The processor runs in &lt;code&gt;without sharing&lt;/code&gt; mode to ensure articles can be created regardless of running user. Adjust based on your security requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Draft vs. Publish&lt;/strong&gt; -- This solution creates drafts intentionally. If you want auto-publishing, modify the processor to call &lt;code&gt;KbManagement.PublishingService.publishArticle()&lt;/code&gt; after creation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;Once you have Confluence syncing to Knowledge, consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Connecting to Agentforce&lt;/strong&gt; -- Your AI agents can now reference this knowledge in responses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customer Community&lt;/strong&gt; -- Publish relevant articles to your community for customer self-service&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Einstein Search&lt;/strong&gt; -- Improved search results across your unified knowledge base&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;By combining Data Cloud's Confluence connector with Data Transforms and targeted Apex, you can create an automated pipeline from your team's documentation tool into Salesforce Knowledge. No more copy-paste, no more outdated articles -- just automated, reliable knowledge syncing.&lt;/p&gt;

&lt;p&gt;If you have questions about this implementation or want to discuss specific use cases, feel free to reach out! More on how I approach these projects on the &lt;a href="https://modernstacksystems.com/data-cloud/" rel="noopener noreferrer"&gt;Data Cloud consulting&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;Connect with me on &lt;a href="https://www.linkedin.com/in/maciej-nosek/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or subscribe to my &lt;a href="https://www.youtube.com/channel/UCAQy8EU5LIY4LD_FTQOKAJw" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt; for more Salesforce content.&lt;/p&gt;

</description>
      <category>datacloud</category>
      <category>salesforceknowledge</category>
      <category>confluence</category>
      <category>apex</category>
    </item>
    <item>
      <title>Agentforce Apex Actions: Building Custom Invocable Actions for Your Agents</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Thu, 14 Aug 2025 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/agentforce-apex-actions-building-custom-invocable-actions-for-your-agents-39h4</link>
      <guid>https://dev.to/modernstackmac/agentforce-apex-actions-building-custom-invocable-actions-for-your-agents-39h4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzgib9julz05yp4ink8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzgib9julz05yp4ink8r.png" alt="Extending Agentforce with Apex Invocable Actions" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes the standard Agentforce actions just aren't enough. When you need to bring in external data, apply complex business logic, or make API calls, you'll need to extend your agents with custom Apex code.&lt;/p&gt;

&lt;p&gt;In this guide, I'll walk you through building a stock price agent that fetches real-time stock prices using Apex invocable actions. This demonstrates the pattern you can apply to any scenario where you need to go beyond point-and-click configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We're Building
&lt;/h2&gt;

&lt;p&gt;I built an employee agent that can fetch current stock prices for any ticker symbol. When users ask "What's the price of CRM?" or "Can you tell me the price of NVDA?", the agent makes a live API call and returns the current stock price.&lt;/p&gt;

&lt;p&gt;The agent handles multiple requests back to back -- you can ask about CRM ($233.63), then immediately ask about another stock, and it fetches fresh data each time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Video Walkthrough
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Mumr-XPilfw" rel="noopener noreferrer"&gt;Watch on YouTube&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Apex Invocable Actions?
&lt;/h2&gt;

&lt;p&gt;Use Apex invocable actions when you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Make external API calls&lt;/strong&gt; -- Connect to third-party services for real-time data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply complex filter logic&lt;/strong&gt; -- Business rules too complex for standard actions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handle advanced business rules&lt;/strong&gt; -- Custom validation or processing logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bring in extra data&lt;/strong&gt; -- Information not available through standard Salesforce actions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apex gives you the flexibility to handle scenarios that standard configurations can't address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent Configuration: Keep It Simple
&lt;/h2&gt;

&lt;p&gt;The key lesson I've learned: &lt;strong&gt;keep your agent topics very high-level&lt;/strong&gt;. Don't overcomplicate with step-by-step instructions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Topic Setup
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzvzd1wmxbofy0q9ygs0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzvzd1wmxbofy0q9ygs0s.png" alt="Agent topic configuration for stock price" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Name:&lt;/strong&gt; Get Stock Price&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt; User will prompt by passing in a ticker symbol to get current stock price&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instructions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the Apex class attached to the asset&lt;/li&gt;
&lt;li&gt;If user provides multiple ticker symbols, process them one at a time&lt;/li&gt;
&lt;li&gt;If the action fails, inform the user that the price couldn't be retrieved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Make your topics non-deterministic. Avoid rules like "first do this, second do this, never do X if you don't have Y." The agent gets confused with overly specific instructions and rarely produces expected results.&lt;/p&gt;

&lt;p&gt;Keep it simple: name your topics clearly, provide high-level context, and let the agent handle the execution details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Asset Configuration
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqmn45krus7evadyx3cje.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqmn45krus7evadyx3cje.png" alt="Agent asset configuration connecting topic to Apex" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The asset connects your topic to the Apex action:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instructions:&lt;/strong&gt;"Retrieve the ticker symbol parameter, run the Apex class, and return the output"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;symbol&lt;/strong&gt; (Text) -- Ticker symbol (1-5 uppercase letters)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Output Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;result&lt;/strong&gt; (Text) -- String response with the stock price&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Apex Implementation
&lt;/h2&gt;

&lt;p&gt;Here's the complete Apex class for fetching stock prices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StockPriceInvocable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@InvocableMethod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Get Stock Price'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getStockPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'/api/v1/quote?symbol='&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nc"&gt;EncodingUtil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urlEncode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'UTF-8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nc"&gt;HttpRequest&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setEndpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'callout:StockPrice'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setMethod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'GET'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nc"&gt;Http&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Http&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;HttpResponse&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStatusCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deserializeUntyped&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;containsKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nc"&gt;Decimal&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'The current price for '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' is '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;valueOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'No price data available for '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Error getting stock price: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'Could not get price for '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' at this time'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Implementation Notes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Invocable Methods Always Use Lists
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Critical:&lt;/strong&gt; Invocable methods always expect and return lists, even for single values. You can't pass a single string -- it must be &lt;code&gt;List&amp;lt;String&amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Input parameter&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getStockPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Always index into the first element for single values&lt;/span&gt;
    &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Always return a list&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Authentication with Named Credentials
&lt;/h3&gt;

&lt;p&gt;Use Named Credentials for secure API authentication. In the endpoint URL, reference your named credential:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;endpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'callout:Stock_API/quote/'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This handles authentication automatically without hardcoding credentials in your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Error Handling
&lt;/h3&gt;

&lt;p&gt;Always include proper error handling for external API calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// API call logic&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStatusCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Success logic&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Handle API errors&lt;/span&gt;
        &lt;span class="n"&gt;responses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Cannot retrieve price for ticker symbol: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Handle system errors&lt;/span&gt;
    &lt;span class="n"&gt;responses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Cannot retrieve price for ticker symbol: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Patterns
&lt;/h2&gt;

&lt;p&gt;For more complex scenarios, use inner classes to organize multiple inputs and outputs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StockDataInvocable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StockInput&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;Boolean&lt;/span&gt; &lt;span class="n"&gt;includeMetrics&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StockOutput&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;companyName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nd"&gt;@InvocableVariable&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;marketCap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@InvocableMethod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Get Detailed Stock Data'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StockOutput&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getDetailedStockData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StockInput&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Implementation&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach keeps your code organized when dealing with multiple parameters instead of managing long parameter lists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing Your Implementation
&lt;/h2&gt;

&lt;p&gt;Test your Apex class independently before connecting it to the agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Test in Anonymous Apex&lt;/span&gt;
&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;testSymbols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'CRM'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StockPriceInvocable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStockPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;testSymbols&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Result: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the Apex works correctly, test the full agent integration with natural language prompts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Pitfalls to Avoid
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Over-complicated Instructions:&lt;/strong&gt; Don't give the agent detailed step-by-step rules. Keep topic instructions high-level and let the agent figure out execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Synchronous Processing:&lt;/strong&gt; External API calls add latency. Design your user experience accordingly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single String Parameters:&lt;/strong&gt; Remember that invocable methods always work with lists, not individual values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Missing Error Handling:&lt;/strong&gt; Always account for API failures and provide meaningful error messages to users.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use This Pattern
&lt;/h2&gt;

&lt;p&gt;Use Apex invocable actions when you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connect to external APIs for real-time data&lt;/li&gt;
&lt;li&gt;Apply business logic too complex for standard flows&lt;/li&gt;
&lt;li&gt;Process data in ways not supported by standard actions&lt;/li&gt;
&lt;li&gt;Integrate with legacy systems or custom databases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For simpler scenarios like basic record updates or queries, stick with standard Agentforce actions. They're faster to configure and easier to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;This pattern opens up countless possibilities for extending your Agentforce agents. You could build integrations with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Financial data providers&lt;/li&gt;
&lt;li&gt;Weather services&lt;/li&gt;
&lt;li&gt;Inventory management systems&lt;/li&gt;
&lt;li&gt;Custom business applications&lt;/li&gt;
&lt;li&gt;Legacy databases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key is starting simple, like this stock price example, then expanding as your needs grow.&lt;/p&gt;

&lt;p&gt;Need custom actions like this built into a production agent? That's part of every &lt;a href="https://modernstacksystems.com/agentforce/" rel="noopener noreferrer"&gt;Agentforce implementation&lt;/a&gt; I run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;Connect with me on &lt;a href="https://www.linkedin.com/in/maciej-nosek/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or subscribe to my &lt;a href="https://www.youtube.com/channel/UCAQy8EU5LIY4LD_FTQOKAJw" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt; for more Salesforce content.&lt;/p&gt;

</description>
      <category>agentforce</category>
      <category>apex</category>
      <category>invocableactions</category>
      <category>apiintegration</category>
    </item>
    <item>
      <title>How to Invoke Agentforce Agents from Apex and Flow (Headless Agents)</title>
      <dc:creator>Mac Nosek</dc:creator>
      <pubDate>Fri, 08 Aug 2025 14:00:00 +0000</pubDate>
      <link>https://dev.to/modernstackmac/how-to-invoke-agentforce-agents-from-apex-and-flow-headless-agents-24mi</link>
      <guid>https://dev.to/modernstackmac/how-to-invoke-agentforce-agents-from-apex-and-flow-headless-agents-24mi</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1gis2k139krmlwunxh2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1gis2k139krmlwunxh2h.png" alt="Agentforce headless agents overview" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On a recent project, I needed to figure out how to trigger Agentforce agents from Salesforce automation instead of just the chatbot interface. After some digging, I found you can do this with headless agents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; use the Generate AI Agent Response action (&lt;code&gt;generateAiAgentResponse&lt;/code&gt; in Apex). Call it from an after-save record-triggered Flow, or from a Queueable in Apex. Either way it has to run async, and the response comes back as JSON with the text in a &lt;code&gt;value&lt;/code&gt; field.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Headless Agents?
&lt;/h2&gt;

&lt;p&gt;Headless agents are Agentforce running without the chat interface. They get triggered automatically by things like record changes or scheduled processes, which means you can build AI into your normal Salesforce workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;For this example, I created an agent that automatically generates account summaries when specific checkboxes are checked. Simple use case, but it demonstrates the concept well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=1vHmoliwvew" rel="noopener noreferrer"&gt;Watch on YouTube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The idea is that when a sales rep gets assigned a new account, they can quickly understand what the company does, how big they are, and how to approach them -- all generated automatically by Agentforce.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm2czvnotwtwcvtd9jfvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm2czvnotwtwcvtd9jfvy.png" alt="Agent summary output on account record" width="800" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing I noticed -- the AI responses are always slightly different each time you run them. That's just how AI works. Try asking ChatGPT the same question twice, and you'll see what I mean.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Agent
&lt;/h2&gt;

&lt;p&gt;First, you need an employee agent with at least one topic. I called mine "Account Summary" and kept the setup straightforward.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8nn66exz6omlk194dv3y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8nn66exz6omlk194dv3y.png" alt="Agentforce agent topic configuration" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt; I made sure to include what would trigger this topic -- phrases such as "summarize account with the name [Account Name]" or "run an account summary on [Account Name]". This helps the agent understand when to use this topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instructions:&lt;/strong&gt; Important lesson I learned. Don't overthink the instructions! Keep them high-level and let Agentforce handle the execution details. The instruction order doesn't matter -- everything gets compiled into a JSON object.&lt;/p&gt;

&lt;p&gt;I used two actions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The standard "Get Record by Name" action&lt;/li&gt;
&lt;li&gt;A custom prompt template I built in Prompt Builder&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkar0xtaxm8ncohet8524.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkar0xtaxm8ncohet8524.png" alt="Agent actions configuration" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The prompt template is basic -- it tells the AI to create a 2-4 sentence summary using key account fields such as industry, revenue, employee count, and other relevant data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu9gnoj4myerc0uoqjo0c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu9gnoj4myerc0uoqjo0c.png" alt="Prompt template configuration in Prompt Builder" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 1: The Flow Approach
&lt;/h2&gt;

&lt;p&gt;If you prefer clicks over code, the Flow approach is simple.&lt;/p&gt;

&lt;p&gt;Important note: this needs to run asynchronously. Make sure your flow is configured to run after the record is saved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw474k3hntbxyvvgtim13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw474k3hntbxyvvgtim13.png" alt="Flow trigger configuration" width="644" height="701"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the basic flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Triggered when the account is updated&lt;/li&gt;
&lt;li&gt;Check if the "Flow Agent" checkbox is true&lt;/li&gt;
&lt;li&gt;Call the "Generate AI Agent Response" action&lt;/li&gt;
&lt;li&gt;Parse the JSON response to get just the summary text&lt;/li&gt;
&lt;li&gt;Update the account record&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4u2u3lnbw4dp8lksae3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4u2u3lnbw4dp8lksae3w.png" alt="Complete flow structure" width="628" height="768"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tricky part is parsing the response. It comes back as JSON with the actual summary buried in a "value" field:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz7ppwhnnddfl661k2fbc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz7ppwhnnddfl661k2fbc.png" alt="JSON response structure" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Einstein Logic Labs, an installation partner..."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Option 2: The Apex Approach
&lt;/h2&gt;

&lt;p&gt;I prefer the Apex approach because you get more control, especially when dealing with JSON parsing. Flows can be finicky with complex data structures. With Apex, you can use &lt;a href="https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Json.htm" rel="noopener noreferrer"&gt;Salesforce's JSON class&lt;/a&gt; when you need to handle JSON structures.&lt;/p&gt;

&lt;p&gt;Both approaches require asynchronous processing since Agentforce calls take time (they're hitting external AI services). I use a queueable class for this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nf"&gt;accountSummaryAgentQueueable&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Queueable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;accountIds&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;accountSummaryAgentQueueable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;accountIds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accountIds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;accountIds&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;QueueableContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Account&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;accountsToUpdate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Account&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Account&lt;/span&gt; &lt;span class="n"&gt;acc&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;SELECT&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="no"&gt;FROM&lt;/span&gt; &lt;span class="nc"&gt;Account&lt;/span&gt; &lt;span class="no"&gt;WHERE&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="no"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;accountIds&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;userMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'run an account summary on '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;agentResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agentforceHeadlessAgentApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;callAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Account_Summary_Agent'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;userMessage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;parsedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseAgentResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agentResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                &lt;span class="nc"&gt;Account&lt;/span&gt; &lt;span class="n"&gt;accountToUpdate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Account&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="nc"&gt;Agent_Summary_Apex__c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parsedValue&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="n"&gt;accountsToUpdate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;accountToUpdate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Error processing account '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;': '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="n"&gt;accountsToUpdate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Error updating accounts: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;parseAgentResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;jsonResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deserializeUntyped&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;jsonResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Error parsing agent response: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'Error parsing agent response: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The core functionality happens in the agentforceHeadlessAgentApi service class, where you call the agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apex"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nf"&gt;agentforceHeadlessAgentApi&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="no"&gt;AGENT_AI_ACTION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'generateAiAgentResponse'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;callAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;agentName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;userMessage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;Invocable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Action&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Invocable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createCustomAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;AGENT_AI_ACTION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agentName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setInvocationParameter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'userMessage'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;userMessage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Invocable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nc"&gt;Invocable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isSuccess&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getOutputParameters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'agentResponse'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'Error: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getErrors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'Error: '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The best part is that this all works natively in Salesforce. No external integrations or credential setup -- just use the built-in invocable actions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flow vs Apex -- When to Use What
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use Flow if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want something simple and declarative&lt;/li&gt;
&lt;li&gt;Your team doesn't have developers&lt;/li&gt;
&lt;li&gt;The logic is straightforward&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use Apex if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need complex JSON handling&lt;/li&gt;
&lt;li&gt;You want better error handling&lt;/li&gt;
&lt;li&gt;You're already working in an Apex-heavy org&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both approaches work well. I find Apex more reliable when things get complicated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Issues I Encountered
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Performance:&lt;/strong&gt; These calls aren't instant. Don't try to run them synchronously or you'll hurt your performance. Always use async processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI Variability:&lt;/strong&gt; As I mentioned, you won't get identical responses every time. That's normal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instructions:&lt;/strong&gt; Don't overcomplicate the agent instructions. I initially tried to be very specific about the order of operations, but learned that doesn't work well. Keep it high-level.&lt;/p&gt;

&lt;p&gt;That covers the basics of calling Agentforce agents from your Salesforce automation. Both approaches work well. Flows are great for simpler scenarios and teams that prefer declarative solutions, while Apex gives you more control for complex implementations. Pick whichever fits your team's comfort level and requirements.&lt;/p&gt;

&lt;p&gt;If you're past the proof of concept and want agents like this running in production, that's the work I do on &lt;a href="https://modernstacksystems.com/agentforce/" rel="noopener noreferrer"&gt;Agentforce implementations&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;Connect with me on &lt;a href="https://www.linkedin.com/in/maciej-nosek/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or subscribe to my &lt;a href="https://www.youtube.com/channel/UCAQy8EU5LIY4LD_FTQOKAJw" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt; for more Salesforce content.&lt;/p&gt;

</description>
      <category>agentforce</category>
      <category>apex</category>
      <category>flows</category>
      <category>headlessagents</category>
    </item>
  </channel>
</rss>
