Conversation

class Conversation

A Conversation represents a conversation that is about to be created, fetched, or updated. You can use this object to set up or modify a conversation before showing it. Note: any changes you make here will not be sent to TalkJS immediately. Instead, instantiate a TalkJS UI using widgets such as ChatBox.

NOTE: A Conversation object is created by calling the getConversation method of the Session object.

Available Methods

sendMessageSends a text message in a given conversation.

Available Properties

id
String

A unique identifier for this conversation, such as a channel name or topic ID. Any user with access to this ID can join this conversation. Read about how to choose a good conversation ID for your use case If you want to make a simple one-on-one conversation, consider using oneOnOneId to generate one.

custom
Map<String, String?>?

Allows custom conversation metadata to be stored in the form { "name": "string" }

photoUrl
String?

An optional URL to a photo which will be shown as the photo for the conversation.

subject
String?

An optional conversation subject which will be displayed in the chat header.

welcomeMessages
List<String>?

Messages which are sent at the beginning of a chat. In this case the messages will appear as system messages.

participants
(optional)Set<Participant>

A set containing the participants for this conversation.

sendMessage

1Future<void> sendMessage(String text, {SendMessageOptions? options});

Sends a text message in a given conversation.

Parameters

text
String

The message body that is to be sent.

options
(optional)SendMessageOptions?

Custom metadata that is stored with the message.

See SendMessageOptions

Returns

Future<void>


class Participant

This represents a participant of the conversation.

Available Methods

ConstructorSets a participant of the conversation.

Constructor

1Participant(User user, {ParticipantAccess? access, bool? notify});

Sets a participant of the conversation.

NOTE: All the parameters passed to the constructor are also available as read-only properties of the constructed object.

Parameters

user
User

A User object that identifies the person who is a participant of the conversation.

access
(optional)ParticipantAccess.read | ParticipantAccess.readWrite | null

Specifies the participant's access permission for a conversation.

notify
(optional)ParticipantNotification?

BREAKING CHANGE: Before Flutter SDK version 0.4.0 this property was of type bool?

Specifies the participants's notification settings.


class SendMessageOptions

Sets custom metadata that is stored with the message.

Available Methods

ConstructorSets custom metadata that is stored with the message.

Constructor

1SendMessageOptions({required Map<String, String?> custom});

Sets custom metadata that is stored with the message.

NOTE: All the parameters passed to the constructor are also available as read-only properties of the constructed object.

Parameters

custom
Map<String, String?>

Custom metadata that is stored with the message.

Set any property to null to delete the existing value (if any). When omitted, the existing value remains unchanged.