clean-mouse-53726
10/30/2025, 9:38 AMtall-airline-16756
10/30/2025, 9:38 AMtall-airline-16756
10/30/2025, 9:38 AMsendText in LiveKit! You can do this by using the attributes field within the SendTextOptions parameter. This lets you attach key-value metadata to your text message, which recipients can then access when they handle incoming text streams.
Here’s a simple example using the Flutter SDK:
final testAttributes = {'userId': '12345', 'sessionId': 'abc123', 'priority': 'high'};
final info = await room.localParticipant?.sendText('Test message with metadata',
options: SendTextOptions(
topic: 'chat-metadata',
attributes: testAttributes, // Attach metadata here
));
And on the receiving side, you can handle it like this:
room.registerTextStreamHandler('chat-metadata', (TextStreamReader reader, String participantIdentity) async {
final text = await reader.readAll();
print('Received attributes: ${reader.info?.attributes}');
// Access specific metadata
print('User ID: ${reader.info!.attributes['userId']}');
});
This feature is also available in other SDKs like Python and JavaScript/TypeScript. If you'd like, I’d be more than happy to provide examples for those or assist you further. Just let me know!
Sources: lib/src/participant/local.dart | livekit-rtc/livekit/rtc/participant.py | src/room/participant/LocalParticipant.ts | Sending text | LiveKit docs