Other interfaces

class SendMessageEvent

Available Properties

conversation
ConversationData

Information about the current conversation object

me
UserData

Information about the current TalkJS user.

message
SentMessage

The message that was sent


class TranslationToggledEvent

Available Properties

conversation
ConversationData

Conversation for which translation has been toggled

isEnabled
bool

Boolean indicating if translation is enabled or not


class MessageActionEvent

Available Properties

action
String

The custom action

message
Message

Information about the message on which the action was called


class ConversationActionEvent

Available Properties

action
String

The custom action

conversationData
ConversationData

Information about the conversation on which the action was called


class SelectConversationEvent

Available Properties

conversation
ConversationData

Information about the selected conversation object

me
UserData

Information about the current TalkJS User

others
List<UserData>

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


class Unreads

Constructor

1Unreads({
2 UnreadsChangeHandler? onChange;
3});

Parameters

onChange
UnreadsChangeHandler

Triggered when the list of unread conversations changes.


UnreadsChangeHandler

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

See UnreadConversation for the callback parameter.


class UnreadConversation
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
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
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
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:

1[51.481083, -3.178306]

class Message
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:

1[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
url
String

URL of the given file.

size
int

Filesize (in bytes) of the given file.


class ThemeOptions

Constructor

1ThemeOptions({
2 String? name,
3 Map<String, dynamic>? custom,
4});

Parameters

name
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
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),

Available Methods

ConstructorCreates a ConversationPredicate

Constructor

1const ConversationPredicate({
2 FieldPredicate<ConversationAccessLevel>? access,
3 Map<String, CustomFieldPredicate>? custom,
4 bool? hasUnreadMessages,
5 NumberPredicate? lastMessageTs,
6 FieldPredicate<String?>? subject,
7});

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

Parameters

access
(optional)FieldPredicate<ConversationAccessLevel>?

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),

Available Methods

CompoundConversationPredicate.anyCreates a CompoundConversationPredicate that matches any of the ConversationPredicates in the list

CompoundConversationPredicate.any

1CompoundConversationPredicate.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),

Available Methods

ConstructorCreates a MessagePredicate

Constructor

1const MessagePredicate({
2 Map<String, CustomFieldPredicate>? custom,
3 FieldPredicate<MessageOrigin>? origin,
4 SenderPredicate? sender,
5 FieldPredicate<MessageType>? type,
6});

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),

Available Methods

CompoundMessagePredicate.anyCreates a CompoundMessagePredicate that matches any of the MessagePredicates in the list

CompoundMessagePredicate.any

1CompoundMessagePredicate.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)

Available Methods

ConstructorCreates a SenderPredicate

Constructor

1const SenderPredicate({
2 FieldPredicate<String>? id,
3 Map<String, CustomFieldPredicate>? custom,
4 FieldPredicate<String>? locale,
5 FieldPredicate<String>? role,
6});

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:

1// Show messages from the user with id 1
2id: 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:

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

class FieldPredicate<T>

Used as properties of ConversationPredicate, MessagePredicate, and SenderPredicate.

Available Methods

ConstructorsCreates a FieldPredicate

Constructors

1FieldPredicate.equals(T value);

Only select if equals to value.

1FieldPredicate.notEquals(T value);

Only select if not equals to value.

1FieldPredicate.oneOf(List<T> values);

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

1FieldPredicate.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.

Available Methods

ConstructorsCreates a NumberPredicate

Constructors

1NumberPredicate.greaterThan(double value);

Only select if greater than value.

1NumberPredicate.lessThan(double value);

Only select if less than value.

1NumberPredicate.greaterOrEquals(double value);

Only select if greater than or equals value.

1NumberPredicate.lessOrEquals(double value);

Only select if less than or equals value.

1NumberPredicate.between(List<double> values);

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

1NumberPredicate.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.

Available Methods

ConstructorsCreates a CustomFieldPredicate

Constructors

1CustomFieldPredicate.equals(String value);

Only select if the custom property value equals to value.

1CustomFieldPredicate.notEquals(String value);

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

1CustomFieldPredicate.oneOf(List<String> values);

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

1CustomFieldPredicate.notOneOf(List<String> values);

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

1CustomFieldPredicate.exists();

Only select if the custom property value exists.

1CustomFieldPredicate.notExists();

Only select if the custom property value not exists.


enum ConversationAccessLevel
none
read
readWrite

enum MessageOrigin
web
rest
email
import

enum MessageType
userMessage
systemMessage

enum LoadingState
loading
loaded

enum ParticipantNotification
off
on
mentionsOnly

class UrlNavigationRequest

Available Properties

url
String

The Url that has been clicked


enum UrlNavigationAction
deny
allow

enum Provider
fcm
apns