Users
A TalkJS user is a person or a group of people who uses your app.
It's usually best practice to map a user in your own database one-to-one to a TalkJS user.
TalkJS only collects the user data needed to make TalkJS work, and nothing else. This includes, for example, information to display a user's name, or send them email notifications.
In the JavaScript Data API, you can create a user with the createIfNotExists method, or set user properties to create or update data.
If you're using the Classic JavaScript SDK to create a user, then TalkJS automatically synchronizes user data while the user is logged into your app. As a result, TalkJS always holds an up-to-date copy of your user.
You can also use the REST API to programmatically create or update user data.
When you send user data to TalkJS, you need to provide a user ID for each user. Each user ID must be:
- Unique: No two distinct users can have the same user ID.
- Permanent: Once assigned, a user must always keep the same user ID. If you change a user's user ID, the user might lose access to their chat.
A best practice is just to use the user ID that's already used inside your own database.
Any time someone loads TalkJS and identifies with a specific user ID, TalkJS can load that user's old messages — even on different devices. Authentication (Identity verification) makes this secure.
Sometimes it can be effective to make a group of users act as a single TalkJS user. For example, a team of colleagues may want to chat on your platform with another person, but it should appear as if it's a single person talking.
In this case, send a user ID to TalkJS that is not the same as your users' real ID. For instance, it might be appropriate to use the team ID for a TalkJS user ID.
Make sure that user IDs don't collide. If you use increasing numbers for both your user IDs and your team IDs, then TalkJS will think that user 5 and team 5 is the same user. If this might happen, it may be better to prefix your TalkJS user IDs, for example turn it into "team_5" and "user_5" or something like that.
TalkJS takes privacy seriously, and only uses your user data where TalkJS features require it. Because of this:
- TalkJS doesn't track your user's behavior
- Sensitive data is
[suppressed]when obtained from the JavaScript Data API or classic Javascript SDK. To access these fields, you can use the REST API. - TalkJS doesn't contact your users, except to send them chat notifications.
If you want to ban a user, follow this tutorial on how to ban a user from all chats. The tutorial also showcases how to ensure the integrity of your user's data by using authentication (identity verification) and disabling client-side conversation syncing.
- UserRef and UserSnapshot in the JavaScript Data API reference
/usersin the REST API