User object

User refers to a single user in a chat.

Properties

The User class has the following properties:

public class User : UniqueChatEntity {
public string Id { get; protected set; }
public string UserName { get; }
public string ExternalId { get; }
public string ProfileUrl { get; }
public string Email { get; }
public string CustomData { get; }
public string Status { get; }
public string DataType { get; }
public bool Active { get; }
public string LastActiveTimeStamp { get; }
}
ParameterTypeDescription
IdstringUnique identifier for the user.
UserNamestringDisplay name or username of the user.
ExternalIdstringIdentifier for the user from an external system, such as a database or CRM.
ProfileUrlstringURL to the user's profile or avatar image.
EmailstringUser's email address.
CustomDatastringAny custom data that you want to store for the user.
StatusstringCurrent status of the user (e.g., online, offline, away).
DataTypestringType of user's data.
ActiveboolReturned info on whether the user is active (true) or not active (false) on the channel. The returned value depends strictly on how you configure your chat app during initialization - if you set the StoreUserActivityInterval parameter to the default 600000 milliseconds (10 minutes) and the user has been active in the app within the last 10 minutes (based on their LastActiveTimeStamp property), accessing the Active property returns true.
LastActiveTimeStampstringTimestamp for the last time the user was active in a chat app.
API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Events

The User object has the following event:

// Event triggered when the user is updated
public event Action<User> OnUserUpdated;

Example

An event that is triggered when the user is updated by the server.

user.OnUserUpdated += (user) =>
{
Console.WriteLine("User metadata updated!");
};

Methods

You can call the following methods on the User object. Click on each method for more details.

Use case

For example, you can use the User object methods to:

Last updated on