Manage user details
Get details about the app users.
Get user details
Return data about a specific user with the getUser() method.
By default, this method returns all custom user metadata without the need to define that during the call explicitly.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
This method takes the following parameters:
chat.getUser(
id: string
): Promise<User | null>
Input
* required
| Parameter | Description |
|---|---|
id *Type: stringDefault: n/a | Unique user identifier (up to 92 UTF-8 characters). |
Output
| Type | Description |
|---|---|
Promise<User> or Promise<null> | Returned object containing the user metadata or a null value if the user doesn't exist. |
Errors
If you try to fetch a user without providing their ID, you will receive the ID is required error.
Sample code
Get details on user support_agent_15.
// reference the "chat" object and invoke the "getUser()" method
const user = await chat.getUser("support_agent_15")
Get current user
currentUser is a getter method that returns the current chat user of the chat app.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
This method has the following signature:
chat.currentUser: User
Properties
| Property | Description |
|---|---|
currentUserType: User | Returned User object. |
Sample code
Return the current chat user.
chat.currentUser