User

A user of your app. TalkJS uses the id to uniquely identify this user. All other fields of a User are allowed to vary over time and the TalkJS database will update its fields accordingly.

If you have client synchronization enabled, only id and name are required for TalkJS to function. Otherwise, if client synchronization is disabled, then you MUST only have the id present.

Note that without email set to a valid value, TalkJS can't send email notifications to users who are offline.

Example

1{
2 id: "123456789",
3 name: "Alice",
4 email: "[email protected]",
5 photoUrl: "https://talkjs.com/images/avatar-1.jpg",
6 welcomeMessage: "Hey, how can I help?"
7 custom: {
8 country: "ca"
9 },
10 locale: "en-US"
11};

Properties

FieldTypeDescription
id Required
stringThe unique ID which is used to identify the user in TalkJS
name
(optional)
stringThe User's name which will be displayed on the TalkJS UI
email
(optional)
string | string[] | nullZero or more email address used for email notifications if enabled
phone
(optional)
string | string[] | nullZero or more phone numbers used for SMS notifications
welcomeMessage
(optional)
string | nullThe default message a user sees when starting a chat with that person
photoUrl
(optional)
string | nullURL to a photo which will be displayed as the user's avatar
role
(optional)
string | nullOne of the user roles that you can set up from the Roles page of your TalkJS dashboard. You can vary many settings per user role, such as the content of their email or SMS notification, the look and feel of the UIs, and forbidden words.
Make sure the role corresponds precisely to a role name you chose in the dashboard.
custom
(optional)
CustomData | nullJSON-structured custom data that you wish to associate to this user. TalkJS does nothing with this data except make it available in the events that we send to your code and in your Email/SMS notification templates. You can use custom data for all kinds of purposes, such as customizing a user's email notification text, transmitting contextual user data, or making email login tokens
availabilityText
(optional)
string | nullAvailability acts similarly to welcomeMessage but appears as a system message.
locale
(optional)
string | nullAn IETF language tag that sets a language and date format for this user. Note: you set the default locale for your entire app on the Settings page of your TalkJS dashboard. See the localization documentation.

Used by