Chat Helper API Reference
This page summarizes chat helper and module APIs.
Core Entry Points
ChatMessageDataChatMessageComponentDefaultChatMessageComponentChatTranscriptRenderer<MESSAGE extends ChatMessageData, CTX>ChatUiConfigChatTransportModeChatModule
ChatMessageData
Required:
id()role()body()
Optional defaults:
author()timestamp()
ChatMessageComponent
Renderer-populated fluent methods:
withMessageId(String)withRole(String)withAuthor(String)withTimestamp(String)withBody(Component)
ChatTranscriptRenderer
Factory:
ChatTranscriptRenderer.builder()
Render:
render(Collection<MESSAGE> messages, CTX context)
Builder hooks:
withMessageComponentSupplier(Supplier<? extends ChatMessageComponent>)withBodyTextResolver(BiFunction<MESSAGE, CTX, String>)withAuthorResolver(BiFunction<MESSAGE, CTX, String>)withTimestampResolver(BiFunction<MESSAGE, CTX, String>)withEmptyStateText(String)
ChatUiConfig
Fields:
conversationIdtransportMode(SSE,WEBSOCKET,POLLING)historyEndpointstreamEndpointhistoryTargetSelectorhistorySwappollingIntervalMs
Notes:
conversationIdandhistoryEndpointare required.conversationIdis an app-defined routing key (for exampletopic:123ordm:userA:userB).- URL deep links are optional; embedded-only chat flows are valid.
transportModedefaults toSSEwhen null.- This config defines hook metadata only; transport and history behavior are application-owned.
ChatModule
Factory:
ChatModule.create()
Fluent methods:
withTitle(String)withModuleId(String)withDescription(String)withTranscript(Component)withComposer(Component)withUiConfig(ChatUiConfig)
Behavior:
- Builds chat shell structure with
data-sp-chat-*hook attributes. - Throws if
withUiConfig(...)was not supplied. - Does not load history or open transport connections.