Headless Example: Deploy an Enhanced Chat Agent
In this headless example, you develop a chat agent, test and activate it, and deploy it to an Enhanced Chat v2 channel.
Use your preferred AI assistant, such as Claude Code or Agentforce Vibes.
Step 1: Complete the Prerequisites
Complete all the prerequisites in Headless Examples.
In your terminal, run sf org list. If you see the headless org alias in the list, you’re successfully authenticated.
This example deploys the agent to Enhanced Chat v2, which requires an org where Enhanced Chat v2 is available (Digital Engagement or Service Cloud Unlimited Edition, not a base Developer Edition org). You set up the Enhanced Chat v2 channel later, in Step 5.
Step 2: Build a Customer Service Agent
Copy and paste this prompt into your AI assistant:
1Execute these instructions headlessly without using the UI. Build a customer service agent named "CustomerServiceAgent" capable of Order Tracking, Product Support, and Refund Processing. Don't publish the agent yet.Skill used: agentforce-generate
Your AI assistant creates the agent. We’re not ready to publish and activate it yet.
Step 3: Test the Agent
Copy and paste this prompt into your AI assistant:
1Execute these instructions headlessly without using the UI. Test the agent with realistic customer scenarios and interactions.Skill used: agentforce-test
Your AI assistant generates a test plan and executes the tests. If any tests fail, review the root causes returned by your AI assistant and ask it to apply the recommended fixes.
These tests aren’t saved to a regression test suite. That step is outside the scope of this example.
Note
Step 4: Activate the Agent
Copy and paste this prompt into your AI assistant:
1Execute these instructions headlessly without using the UI. Commit and activate the agent in the org.Skill used: None. Uses Salesforce CLI.
Your AI assistant publishes and activates the agent. The agent must be active before you can route an Enhanced Chat v2 channel to it.
Step 5: Deploy the Agent to an Enhanced Chat v2 Channel
Enhanced Chat v2 runs on Service Cloud’s Messaging and Omni-Channel. Before your AI assistant can deploy to it, Enhanced Chat v2 must be configured and operational in your org. To set it up, see Salesforce Help: Prepare a Salesforce Org for Enhanced Chat and Connect a Service Agent to Enhanced Chat v2.
Copy and paste this prompt into your AI assistant:
1Execute these instructions headlessly without using the UI. Deploy the CustomerServiceAgent to an Enhanced Chat v2 messaging channel. Route the channel to the agent, add a fallback queue for human escalation, and don't enable user verification.Skill used: service-digital-engagement-channel-configure
Your AI assistant:
- Confirms that the agent is active and sets it as the channel’s routing target.
- Creates an Omni-Channel fallback queue that supports the Messaging Session object, if one doesn’t already exist. A fallback queue is required so that conversations can escalate to a human service rep.
- Generates a
MessagingChannelwith Agentforce Service Agent routing to your agent, deploys it, and activates it.
This prompt skips user verification to keep the example simple. User verification uses JWT-based identity and requires an external client app and certificate in your org. To require verified users on a production channel, set that up first, and then enable user verification on the channel.
Note
Step 6: Review the Agent in Your Org
You’ve created an agent headlessly, activated it, and routed it to an Enhanced Chat v2 channel. Now, you can review your work in the UI by running the sf org open Salesforce CLI command. In Setup, check Messaging Settings for your new channel.
Next Steps
Your agent is now connected to an Enhanced Chat v2 channel. To surface the chat to your customers, create and publish an embedded service deployment, and then embed it on your site.
To continue headlessly, your AI assistant can create and publish the deployment with the service-digital-engagement-deployment-configure skill.
Embedding the published deployment varies by where you host the chat, so follow the Service Cloud guidance for your surface:
- Salesforce Help: Configure an Enhanced Web Chat Deployment — for an external website.
- Salesforce Help: Configure an Enhanced Web Chat Deployment in an Experience Builder or Commerce Cloud Site — for a Salesforce-hosted site.
See Also
- Headless Examples
- Salesforce Developers: Enhanced Web Chat Developer Guide — customize and extend Enhanced Chat v2 with JavaScript APIs, Lightning web components, and settings.
- Salesforce Developers: Enhanced Chat API Developer Guide — build directly against the Enhanced Chat messaging APIs.
- Salesforce Help: Connect a Service Agent to Enhanced Chat v2 — the equivalent setup in Agentforce Builder.