Other interfaces

class SendMessageEvent

Properties

conversation
: ConversationData

Information about the current conversation object

Information about the current TalkJS user.

message
: SentMessage

The message that was sent

class TranslationToggledEvent

Properties

conversation
: ConversationData

Conversation for which translation has been toggled

isEnabled
: bool

Boolean indicating if translation is enabled or not

class MessageActionEvent

Properties

action
: String

The custom action

message
: Message

Information about the message on which the action was called

class ConversationActionEvent

Properties

action
: String

The custom action

conversationData
: ConversationData

Information about the conversation on which the action was called

class SelectConversationEvent

Properties

conversation
: ConversationData

Information about the selected conversation object

Information about the current TalkJS User

others
: List<UserData>

The other participants in the conversation that are not the current user

class Unreads

Constructor

Unreads({
UnreadsChangeHandler? onChange;
});

Parameters

Triggered when the list of unread conversations changes.

typedef UnreadsChangeHandler

typedef UnreadsChangeHandler = void Function(List<UnreadConversation> unreadConversations);

See UnreadConversation for the callback parameter.

class UnreadConversation

Properties

conversation
: ConversationData

The ConversationData of the unread conversation.

lastMessage
: Message

Contains the last Message for this conversation.

unreadMessageCount
: int

The number of unread messages in this conversation.

class ConversationData

Properties

id
: String

The ID of the conversation

custom
: Map<String, String?>?

Contains custom metadata for the conversation if it was set using Conversation​.custom.

welcomeMessages
: List<String>?

One or more welcome messages that will display to the user as a SystemMessage

photoUrl
: String?

Contains the URL of a photo was set using Conversation​.subject.

subject
: String?

Contains the conversation subject if it was set using Conversation​.subject.

class UserData

Properties

availabilityText
: String?

Availability acts similarly to welcomeMessage but appears as a system message.

custom
: Map<String, String?>?

Allows you to set custom metadata for the User

email
: List<String>?

One or more email address belonging to the User. The email addresses will be used for Email Notifications if they are enabled.

phone
: List<String>?

One or more phone numbers belonging to the User. The phone number will be used for SMS Notifications (this feature requires standard plan and up).

id
: String

The unqiue ID which is used to identify the user in TalkJS

name
: String

The User's name which will be displayed on the TalkJS UI

locale
: String?

The locale field expects an IETF language tag. See the localization documentation.

photoUrl
: String?

An optional URL to a photo which will be displayed as the user's avatar

role
: String?

TalkJS supports multiple sets of settings, called "roles". These allow you to change the behavior of TalkJS for different users. You have full control over which user gets which configuration.

welcomeMessage
: String?

The default message a user sees when starting a chat with that person

class SentMessage

Properties

id
: String?

The message ID of the message that was sent

conversationId
: String

The ID of the conversation that the message belongs to

type
: MessageType.UserMessage | MessageType.SystemMessage

Identifies the message as either a User message or System message

readBy
: List<String>

Contains an Array of User​.ids that have read the message. Note that readBy is only used for conversations with at most 300 participants, and will be empty for conversations with 301 or more participants.

senderId
: String

Contains the user ID for the person that sent the message

text
: String?

Contains the message's text

attachment
: Attachment?

Only given if the message contains a file. An object with the URL and filesize (in bytes) of the given file.

location
: List<double>?

Only given if the message contains a location. An array of two numbers which represent the longitude and latitude of this location, respectively. Only given if this message is a shared location.

Example:

[51.481083, -3.178306]

class Message

Properties

attachment
: Attachment?

Only given if the message's type equals ContentType.media. An object with the URL and filesize (in bytes) of the given file.

body
: String

Contains the message's content

conversation
: ConversationData

Contains the ConversationData that the message belongs to.

custom
: Map<String, String?>?

Custom metadata that is stored with the conversation

id
: String

The message's ID.

isByMe
: bool

true if the message was sent by the current user.

location
: List<double>?

Only given if the message's type equals ContentType.location. An array of two numbers which represent the longitude and latitude of this location, respectively. Only given if this message is a shared location.

Example:

[51.481083, -3.178306]
origin
: MessageOrigin

Determines how this message was sent: respectively, Via a web browser (or mobile Webview), via the REST API, via reply-to-email, or using the import API.

read
: bool

true if the message has been read, false has not been seen yet

sender
: UserData?

The User that sent the message

senderId
: String?

The senderID (userID) for the person that sent the message

timestamp
: double

UNIX timestamp specifying when the message was sent (UTC, in milliseconds)

type
: ContentType.media | ContentType.text | ContentType.location

Specifies if if the message is media (file), text or a shared location

class Attachment

Properties

url
: String

URL of the given file.

size
: int

Filesize (in bytes) of the given file.

class ThemeOptions

Constructor

ThemeOptions({
String? name,
Map<String, dynamic>? custom,
});

Parameters

name (optional)
: String?

The name of the theme to use in this widget. If no theme name is given, TalkJS will use the theme set in the user's role, falling back to the default theme if the user has no role.

custom (optional)
: Map<String, dynamic>?

A map of values that will be available to your theme under the theme.custom namespace. The values can be anything that can be JSON-serialized. String and numeric values will also be made available as CSS custom properties in themes, available as var(--theme-<key>), where <key> is the value's key in the object.

class ConversationPredicate

Allows you to filter conversations down to a specific subset.

Pass feedFilter to ConversationList.

For example, to hide read conversations, use:

1ConversationList(
2 feedFilter: ConversationPredicate(hasUnreadMessages: true),
3),

To show everything (ie to disable the filter), use an empty object:

1ConversationList(
2 feedFilter: ConversationPredicate(),
3),

Constructor

const ConversationPredicate({
FieldPredicate<ConversationAccessLevel>? access,
Map<String, CustomFieldPredicate>? custom,
bool? hasUnreadMessages,
NumberPredicate? lastMessageTs,
FieldPredicate<String?>? subject,
});

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

Parameters

Only select conversations that the current user as specific access to.

Example:

1// to remove conversations that the user has no access to anymore, do:
2access: FieldPredicate.notEquals(ConversationAccessLevel.none)
custom (optional)
: Map<String, CustomFieldPredicate>?

Only select conversations that have particular custom fields set to particular values.

Every key must correspond to a key in the custom conversation data that you set (by passing custom to Conversation). It is not necessary for all conversations to have these keys.

Examples, assuming you have set a category custom field on your conversations:

1// only show conversations that have no category set:
2custom: { 'category': CustomFieldPredicate.notExists() }
3
4// only show conversations of category "shoes"
5custom: { 'category': CustomFieldPredicate.equals('shoes') }
6
7// only show conversations either category "shoes" or "sandals"
8custom: { 'category': CustomFieldPredicate.oneOf(['shoes', 'sandals']) }
9
10// only show conversations about shoes that are marked visible.
11// this assumes you also have a custom field called `visibility`
12custom: {
13 'category': CustomFieldPredicate.equals('shoes'),
14 'visibility': CustomFieldPredicate.equals('visible'),
15}
hasUnreadMessages (optional)
: bool?

Set this field to only select conversations that have, or don't have any, unread messages.

lastMessageTs (optional)
: NumberPredicate?

Only select conversations that have the last message sent in a particular time interval.

Example:

1// to show only the conversations that have the last message sent after the UNIX timestamp 1679298371586
2lastMessageTs: NumberPredicate.greaterThan(1679298371586)
subject (optional)
: FieldPredicate<String?>?

Only select conversations that have the subject set to particular values.

Example:

1// to show only the conversations that have "Black leather boots" or "Hair Wax 5 Gallons" as the subject
2subject: FieldPredicate.oneOf(["Black leather boots", "Hair Wax 5 Gallons"])

class CompoundConversationPredicate

Allows you to filter conversations down to a specific subset.

Pass feedFilter to ConversationList.

For example, to match all the conversations to which you have read access, or whose custom "accountId" field has the "my_account" value, use the following:

1ConversationList(
2 feedFilter: CompoundConversationPredicate.any([
3 ConversationPredicate(
4 access: FieldPredicate.equals(ConversationAccessLevel.read),
5 ),
6 ConversationPredicate(
7 custom: {
8 'accountId': CustomFieldPredicate.equals('my_account'),
9 },
10 ),
11 ]),
12),

To show everything (that is, to disable the filter), use an empty object:

1ConversationList(
2 feedFilter: ConversationPredicate(),
3),

Constructor

CompoundConversationPredicate.any(List<ConversationPredicate> predicates);

Parameters

predicates
: List<ConversationPredicate>

Only show conversations that match any one of the predicates in the list

class MessagePredicate

Lets you show only specific messages in the chat panel of a ChatBox.

Used in the messageFilter property of the ChatBox.

For example, to hide all system messages (eg only show user messages), do:

1ChatBox(
2 messageFilter: MessagePredicate(type: FieldPredicate.equals(MessageType.userMessage)),
3),

To show all messages (ie disable the filter), just pass an empty object:

1ChatBox(
2 messageFilter: MessagePredicate(),
3),

Constructor

const MessagePredicate({
Map<String, CustomFieldPredicate>? custom,
FieldPredicate<MessageOrigin>? origin,
SenderPredicate? sender,
FieldPredicate<MessageType>? type,
});

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

Parameters

custom (optional)
: Map<String, CustomFieldPredicate>?

Only select messages that have particular custom fields set to particular values.

Every key must correspond to a key in the custom message data that you have set. It is not necessary for all messages to have these keys.

Examples, assuming you have set a category custom field on your messages:

1// Only show messages that have no category set:
2custom: { 'category': CustomFieldPredicate.notExists() }
3
4// Only show messages of that have the category "shoes"
5custom: { 'category': CustomFieldPredicate.equals('shoes') }
6
7// Only show messages that have the 'topic' either "inquiry" or "reservation"
8custom: { 'topic': CustomFieldPredicate.oneOf(['inquiry', 'reservation']) }
9
10// Only show messages about shoes that are marked visible.
11// this assumes you also have a custom field called `visibility`
12custom: {
13 'category': CustomFieldPredicate.equals('shoes'),
14 'visibility': CustomFieldPredicate.equals('visible'),
15}
origin (optional)
: FieldPredicate<MessageOrigin>?

Only show messages that were sent by users (web), through the REST API (rest), via reply-to-email (email) or via the import REST API (import).

For example:

1// Don't show messages that were sent via the REST API
2origin: FieldPredicate.notEquals(MessageOrigin.rest)
sender (optional)
: SenderPredicate?

Only show messages that are sent by a sender that has all of the given properties

For example:

1// Only show messages sent by users with the role of 'admin' and if the user ID is 1.
2sender: SenderPredicate(
3 role: FieldPredicate.equals('admin'),
4 id: FieldPredicate.equals('1'),
5)
type (optional)
: FieldPredicate<MessageType>?

Only show messages of a given type, for example:

1type: FieldPredicate.equals(MessageType.systemMessage),

class CompoundMessagePredicate

Lets you show only specific messages in the chat panel of a ChatBox.

Used in the messageFilter property of the ChatBox.

For example, to match all the messages that are either of the type SystemMessage, or whose sender has the admin role, use the following:

1ChatBox(
2 messageFilter: CompoundMessagePredicate.any([
3 MessagePredicate(
4 type: FieldPredicate.equals(MessageType.systemMessage),
5 ),
6 MessagePredicate(
7 sender: SenderPredicate(
8 role: FieldPredicate.equals('admin'),
9 ),
10 ),
11 ]),
12),

To show everything (that is, to disable the filter), use an empty object:

1MessageList(
2 feedFilter: MessagePredicate(),
3),

Constructor

CompoundMessagePredicate.any(List<MessagePredicate> predicates);

Parameters

predicates
: List<MessagePredicate>

Only show messages that match any one of the predicates in the list

class SenderPredicate

Used as the sender property of MessagePredicate.

Only show messages that are sent by a sender that has all of the given properties

For example:

1// Only show messages sent by users with the role of 'admin' and if the user ID is 1.
2sender: SenderPredicate(
3 role: FieldPredicate.equals('admin'),
4 id: FieldPredicate.equals('1'),
5)

Constructor

const SenderPredicate({
FieldPredicate<String>? id,
Map<String, CustomFieldPredicate>? custom,
FieldPredicate<String>? locale,
FieldPredicate<String>? role,
});

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

Parameters

id (optional)
: FieldPredicate<String>?

Only select users with a given id.

For example:

// Show messages from the user with id 1
id: FieldPredicate.equals('1')
custom (optional)
: Map<String, CustomFieldPredicate>?

Only select users that have particular custom fields set to particular values.

Every key must correspond to a key in the custom user data that you have set. It is not necessary for all users to have these keys.

locale (optional)
: FieldPredicate<String>?

Only select users with a given locale.

role (optional)
: FieldPredicate<String>?

Only select users with a given role.

For example:

// Show messages from the users with role of 'admin'
role: FieldPredicate.equals('admin')

class FieldPredicate<T>

Used as properties of ConversationPredicate, MessagePredicate, and SenderPredicate.

Constructors

FieldPredicate.equals(T value);

Only select if equals to value.

FieldPredicate.notEquals(T value);

Only select if not equals to value.

FieldPredicate.oneOf(List<T> values);

Only select if the value is one of those in the list.

FieldPredicate.notOneOf(List<T> values);

Only select if the value is not one of those in the list.

class NumberPredicate<T>

Used as properties of ConversationPredicate.

Constructors

NumberPredicate.greaterThan(double value);

Only select if greater than value.

NumberPredicate.lessThan(double value);

Only select if less than value.

NumberPredicate.greaterOrEquals(double value);

Only select if greater than or equals value.

NumberPredicate.lessOrEquals(double value);

Only select if less than or equals value.

NumberPredicate.between(List<double> values);

Only select if the value is between the first and the second value of the list.

NumberPredicate.notBetween(List<double> values);

Only select if the value is not between the first and the second value of the list.

class CustomFieldPredicate

Used as the values for the custom property of ConversationPredicate, MessagePredicate, and SenderPredicate.

Constructors

CustomFieldPredicate.equals(String value);

Only select if the custom property value equals to value.

CustomFieldPredicate.notEquals(String value);

Only select if the custom property value not equals to value.

CustomFieldPredicate.oneOf(List<String> values);

Only select if the custom property value is one of those in the list.

CustomFieldPredicate.notOneOf(List<String> values);

Only select if the custom property value is not one of those in the list.

CustomFieldPredicate.exists();

Only select if the custom property value exists.

CustomFieldPredicate.notExists();

Only select if the custom property value not exists.

enum ConversationAccessLevel

Values

none
read
readWrite

enum MessageOrigin

Values

web
rest
email
import

enum MessageType

Values

userMessage
systemMessage

enum LoadingState

Values

loading
loaded

enum ParticipantNotification

Values

off
on
mentionsOnly

class UrlNavigationRequest

Properties

url
: String

The Url that has been clicked

enum UrlNavigationAction

Values

deny
allow

enum Provider

Values

fcm
apns