Build a Headless Experience

This approach is for developers who want to build a completely custom UI or run agent interactions in the background. The AgentforceService handles the communication and state, emitting events via Kotlin Flows that your app uses to update its own UI or trigger logic.

Use the AgentforceServiceProvider to create an AgentforceService instance for a specific agent.

To send a message to the agent programmatically, you can use a method like sendUtterance on your AgentforceConversation object:

To receive messages from the agent, you can use the conversationManager property on the AgentforceConversation object: