Build a Headless Experience

Agentforce SDK also supports a headless experience for Agentic Use Cases that do not require a chat style interaction. The headless experience can also be used to build your own UI entirely.

Send Messages 

To send a message to the agent, you can use the sendUtterance method on the AgentConversation object.

1await conversation.sendUtterance(utterance: "Hello, world!", attachment: nil)

Receive Messages 

To receive messages from the agent, you can subscribe to the messages publisher on the AgentConversation object.

1conversation.messages
2    .sink { messages in
3        // Handle new messages
4        for message in messages {
5            print(message.message)
6        }
7    }
8    .store(in: &cancellables)

A message is an instance of an AgentforceMessage which includes a message property containing the primary text response from the agent and components which may contain rich UI component definitions for the response.

Next Steps