Delete users
Two DeleteUser() methods let you permanently remove an existing user from the App Context storage ("hard delete").
Both of these methods give the same output. The only difference is that you call a given method either on the Chat or the User object. Depending on the object, these methods take a different set of input parameters - you either have to specify the user ID you want to delete or not because it's already known.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
These methods take the following parameters:
-
DeleteUser()(on theUserobject)user.DeleteUser() -
DeleteUser()(on theChatobject)chat.DeleteUser(
string userId
)
Input
| Parameter | Required in the User object | Required in the Chat object | Description |
|---|---|---|---|
userIdType: stringDefault: n/a | No | Yes | Unique user identifier (up to 92 UTF-8 characters). |
Output
An awaitable Task.
Sample code
Delete the user with an ID of support_agent_15.
-
DeleteUser()if (!chat.TryGetUser("support_agent_15", out var user))
{
Console.WriteLine("Couldn't find user!");
return;
};
await user.DeleteUser() -
DeleteUser()await chat.DeleteUser("support_agent_15")