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:

[INFORMATION NEEDED: How does session management work in the headless Android SDK?]

Based on the preserved content in temp-content.md, there are extensive examples of:

  • Session lifecycle management
  • Streaming response handling
  • Event processing
  • Error handling

These examples should be reviewed and incorporated from the temp-content.md file.

[INFORMATION NEEDED: What additional headless capabilities exist?]

  • What other methods are available on AgentforceService?
  • How do you handle different message types?
  • What about conversation state management?
  • How do you handle errors in headless mode?
  • What about conversation lifecycle management?