Basic Usage
Sometimes during a persona session, you may wish to force a response from the persona. For example, when the user interacts with an element on the page or when you have disabled the Anam LLM to use your own. To do this, use thetalk method:
To learn more about how to use the
talk method to enable your own custom intelligence, see our Custom Brains guide.Streaming Talk Input
For more advanced use cases, you can stream messages to the persona in multiple chunks. This is particularly useful when streaming output from a custom LLM to reduce latency.One talkMessageStream represents one “turn” in the conversation. Once that turn is over, the stream can no longer be used and you must create a new
TalkMessageStream.End of Speech and Interruptions
A conversation “turn” can end in one of two ways:- End of speech: When
streamMessageChunkis called withendOfSpeech: trueor theendMessage()method is called - User interruption: When the user speaks during the stream, triggering an
AnamEvent.TALK_STREAM_INTERRUPTEDevent
TalkMessageStream object is closed and no longer usable. You can check if a stream is still active using:
Correlation IDs
For tracking purposes, you can attach a correlation ID to your talk streams by passing the optionalcorrelationId parameter to the createTalkMessageStream method:
The
correlationId should be unique for every TalkMessageStream instance. When a talk stream is interrupted, this ID will be included in the AnamEvent.TALK_STREAM_INTERRUPTED event.Next Steps
Audio Control
Learn how to control Audio Input in your Anam sessions

