Use LarkChannel for conversational bot and Agent scenarios. It provides a unified entry point for event intake (WebSocket/Webhook), message normalization, safety policies, and messaging (replies, streaming, media).
To get started, create a channel using LarkChannelFactory, define an event handler for message events using NormalizedMessage, and call connect() to resolve the bot's identity.
LarkChannel channel = LarkChannelFactory.createLarkChannel(
LarkChannelOptions.newBuilder(System.getenv("APP_ID"), System.getenv("APP_SECRET"))
.transport("websocket")
.build()
);
channel.on("message", new ChannelEventHandler<NormalizedMessage>() {
@Override
public void handle(NormalizedMessage message) {
channel.send(
message.getChatId(),
SendInput.markdown("Received: " + message.getContent()),
SendOptions.newBuilder().replyTo(message.getMessageId()).build()
);
}
});
BotIdentity identity = channel.connect().get();