Other interfaces
Information about the current conversation object
Information about the current TalkJS user.
The message that was sent
Conversation for which translation has been toggled
Boolean indicating if translation is enabled or not
The custom action
Information about the message on which the action was called
The custom action
Information about the conversation on which the action was called
Information about the selected conversation object
Information about the current TalkJS User
The other participants in the conversation that are not the current user
Unreads({UnreadsChangeHandler? onChange;});
Parameters
Triggered when the list of unread conversations changes.
typedef UnreadsChangeHandler = void Function(List<UnreadConversation> unreadConversations);
See UnreadConversation for the callback parameter.
The ConversationData of the unread conversation.
Contains the last Message for this conversation.
The number of unread messages in this conversation.
The ID of the conversation
Contains custom metadata for the conversation if it was set using Conversation.custom.
One or more welcome messages that will display to the user as a SystemMessage
Contains the URL of a photo was set using Conversation.subject.
Contains the conversation subject if it was set using Conversation.subject.
Availability acts similarly to welcomeMessage but appears as a system message.
Allows you to set custom metadata for the User
One or more email address belonging to the User. The email addresses will be used for Email Notifications if they are enabled.
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).
The unqiue ID which is used to identify the user in TalkJS
The User's name which will be displayed on the TalkJS UI
The locale field expects an IETF language tag. See the localization documentation.
An optional URL to a photo which will be displayed as the user's avatar
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.
The default message a user sees when starting a chat with that person
The message ID of the message that was sent
The ID of the conversation that the message belongs to
Identifies the message as either a User message or System message
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.
Contains the user ID for the person that sent the message
Contains the message's text
Only given if the message contains a file. An object with the URL and filesize (in bytes) of the given file.
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]
Only given if the message's type equals ContentType.media.
An object with the URL and filesize (in bytes) of the given file.
Contains the message's content
Contains the ConversationData that the message belongs to.
Custom metadata that is stored with the conversation
The message's ID.
true if the message was sent by the current user.
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]
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.
true if the message has been read, false has not been seen yet
The User that sent the message
The senderID (userID) for the person that sent the message
UNIX timestamp specifying when the message was sent (UTC, in milliseconds)
Specifies if if the message is media (file), text or a shared location
URL of the given file.
Filesize (in bytes) of the given file.
ThemeOptions({String? name,Map<String, dynamic>? custom,});
Parameters
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.
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.
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),
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)
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() }34// only show conversations of category "shoes"5custom: { 'category': CustomFieldPredicate.equals('shoes') }67// only show conversations either category "shoes" or "sandals"8custom: { 'category': CustomFieldPredicate.oneOf(['shoes', 'sandals']) }910// 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}
Set this field to only select conversations that have, or don't have any, unread messages.
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 16792983715862lastMessageTs: NumberPredicate.greaterThan(1679298371586)
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 subject2subject: FieldPredicate.oneOf(["Black leather boots", "Hair Wax 5 Gallons"])
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),
CompoundConversationPredicate.any(List<ConversationPredicate> predicates);
Parameters
Only show conversations that match any one of the predicates in the list
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),
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
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() }34// Only show messages of that have the category "shoes"5custom: { 'category': CustomFieldPredicate.equals('shoes') }67// Only show messages that have the 'topic' either "inquiry" or "reservation"8custom: { 'topic': CustomFieldPredicate.oneOf(['inquiry', 'reservation']) }910// 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}
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 API2origin: FieldPredicate.notEquals(MessageOrigin.rest)
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)
Only show messages of a given type, for example:
1type: FieldPredicate.equals(MessageType.systemMessage),
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),
CompoundMessagePredicate.any(List<MessagePredicate> predicates);
Parameters
Only show messages that match any one of the predicates in the list
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)
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
Only select users with a given id.
For example:
// Show messages from the user with id 1id: FieldPredicate.equals('1')
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.
Only select users with a given locale.
Only select users with a given role.
For example:
// Show messages from the users with role of 'admin'role: FieldPredicate.equals('admin')
Used as properties of ConversationPredicate, MessagePredicate, and SenderPredicate.
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.
Used as properties of ConversationPredicate.
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.
Used as the values for the custom property of
ConversationPredicate,
MessagePredicate, and
SenderPredicate.
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.
The Url that has been clicked