Manage user updates
Update user details and receive events whenever someone updates them.
Requires App Context
Enable App Context in the Admin Portal to store user data.
Update user details
Edit user metadata with Update() or UpdateUser().
Update()- call on aUserobject (no ID needed)UpdateUser()- call on aChatobject (requires user ID)
Method signature
These methods take the following parameters:
-
Update()1user.Update(ChatUserData updatedData);
2
3public class ChatUserData
4{
5 public string Username { get; set; } = string.Empty;
6 public string ExternalId { get; set; } = string.Empty;
7 public string ProfileUrl { get; set; } = string.Empty;
8 public string Email { get; set; } = string.Empty;
9 public string CustomDataJson { get; set; } = string.Empty;
10 public string Status { get; set; } = string.Empty;
11 public string Type { get; set; } = string.Empty;
12} -
UpdateUser()1chat.UpdateUser(
2 string Id,
3 ChatUserData updatedData
4)
5
6public class ChatUserData
7{
8 public string Username { get; set; } = string.Empty;
9 public string ExternalId { get; set; } = string.Empty;
10 public string ProfileUrl { get; set; } = string.Empty;
11 public string Email { get; set; } = string.Empty;
12 public string CustomDataJson { get; set; } = string.Empty;
13 public string Status { get; set; } = string.Empty;
14 public string Type { get; set; } = string.Empty;
15}
Input
Id#- Required in Update()
- No
- Required in UpdateUser()
- Yes
- property of Id:
Username# - Display name for the user (must not be empty or consist only of whitespace characters).
- Required in Update()
- No
- Required in UpdateUser()
- No
- property of Id:
ExternalId# - User's identifier in an external system. You can use it to match
Idwith a similar identifier from an external database.- Required in Update()
- No
- Required in UpdateUser()
- No
- property of Id:
ProfileUrl# - URL of the user's profile picture.
- Required in Update()
- No
- Required in UpdateUser()
- No
- property of Id:
Email# - User's email address.
- Required in Update()
- No
- Required in UpdateUser()
- No
- property of Id:
CustomDataJson# - JSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported. Filtering App Context data through the custom property is not recommended in SDKs.
- Required in Update()
- No
- Required in UpdateUser()
- No
- property of Id:
Status# - Tag that lets you categorize your app users by their current state. The tag choice is entirely up to you and depends on your use case. For example, you can use
statusto mark users in your chat app asInvited,Active, orArchived.- Required in Update()
- No
- Required in UpdateUser()
- No
- property of Id:
Type# - Tag that lets you categorize your app users by their functional roles. The tag choice is entirely up to you and depends on your use case. For example, you can use
typeto group users by their roles in your app, such asModerator,Player, orSupport-Agent.- Required in Update()
- No
- Required in UpdateUser()
- No
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Output
Both methods return an awaitable Task.
Sample code
Change the link to the user's support_agent_15 LinkedIn profile to https://www.linkedin.com/mkelly_vp2.
-
Update()1 -
UpdateUser()1
Get user updates
Receive updates when User objects are edited or deleted:
StreamUpdates()- monitors a single userStreamUpdatesOn()- monitors multiple users
Both methods accept a callback invoked when user metadata changes. They subscribe to a channel and add an objects event listener for uuid events.
Call StreamUpdates(true) to enable the OnUpdated and OnDeleted events on the user entity. OnUpdated fires when user metadata changes. OnDeleted fires when the user is hard-deleted from App Context.
Method naming
Earlier versions used SetListeningForUpdates() to enable streaming. This method has been superseded by StreamUpdates(), though it remains available for backward compatibility.
Method signature
These methods take the following parameters:
-
StreamUpdates()1user.StreamUpdates(bool stream) -
OnUpdated1// event on the User entity
2public event Action<User> OnUpdated;
3// needs a corresponding event handler
4void EventHandler(User user) -
OnDeleted1// event on the User entity
2public event Action OnDeleted;
3// needs a corresponding event handler
4void EventHandler() -
StreamUpdatesOn()(static)1User.StreamUpdatesOn(
2 List<User> users,
3 Action<User> listener
4)
Input
stream#- Whether to start (
true) or stop (false) listening toUserobject updates.- Required in StreamUpdates()
- Yes
- Required in OnUpdated / OnDeleted
- n/a
- Required in StreamUpdatesOn()
- n/a
users#- List of
Userobjects for which you want to get updates.- Required in StreamUpdates()
- No
- Required in OnUpdated / OnDeleted
- No
- Required in StreamUpdatesOn()
- Yes
listener#- Callback that receives the specific user that was updated.
- Required in StreamUpdates()
- No
- Required in OnUpdated / OnDeleted
- No
- Required in StreamUpdatesOn()
- Yes
Output
These methods don't return a value. Updates are delivered through event handlers or callback functions.
Sample code
-
StreamUpdates()andOnUpdatedGet updates on
support_agent_15.1 -
StreamUpdatesOn()Get updates on
support-agent-1andsupport-agent-2.1