Skip to main content

Users

A user represents an end-user using your application. Users can join channels, chat with other users, receive notifications and perform other actions. Users are identified by a unique name.

Schema

id
required
integer <int64>

64-bit integer identifier associated with this resource

type
required
string
Enum: "PERSON" "BOT"

Type of user

name
required
string

The unique name used to identify this user across ChatKitty. Also known as username

displayName
required
string

Human readable name of this user. Shown to other users

displayPictureUrl
required
string

URL for this user's display picture

isGuest
required
boolean

True if this user was created by a guest user session

required
object (ChatUserPresenceProperties)

Presence status of this user

callStatus
string
Enum: "AVAILABLE" "IN_CALL"

Call presence status of this user

required
object

Custom data associated with this user

object (Links)
{}

Current User

After starting a ChatKitty user session with a client SDK, you can request the current user anytime:

const result = await kitty.getCurrentUser();

const user = result.user; // Handle user

Observing the current user

Get updates when the current user changes by registering an observer function.

const unsubscribe = kitty.onCurrentUserChanged((user) => {
// handle new current user or current user changes
});

// call when you're no longer interested in updates
unsubscribe();
note

The observer function passed to onCurrentUserChanged is called with the current user value when first registered.

Updating the current user

Update the current user by passing a function taking the current user and returning a user with the changes to be applied to your ChatKitty client instance.

await kitty.updateCurrentUser((user) => {
// Perform updates
user.properties = {
...user.properties,
'favorite-number': 42
};

return user; // Return updated user
});

Updating the current user's display picture

Upload a new profile picture for the current user:

await kitty.updateCurrentUserDisplayPicture({ file });

Updating the display picture with an externally hosted picture:

await kitty.updateCurrentUserDisplayPicture({
file: {
url: 'https://example.com/files/jane.png',
name: 'jane.png',
contentType: 'image/png',
size: 123115
}
});

Retrieving a user by ID

You can retrieve a user using both a client SDK or the Platform REST API

const result = await kitty.getUser(USER-ID);

if (result.succeeded) {
const user = result.user; // Handle result
}
const result = await kitty.getUser(USER-ID);

if (succeeded(result)) {
const user = result.user; // Handle result
}
curl "https://api.chatkitty.com/v1/applications/APP-ID/users/USER-ID" -H  "Authorization: Bearer OAUTH-TOKEN"

Observing user online/presence changes

You can listen to changes to user presence changes across your application - when users come online or go offline using a client SDK

kitty.onUserPresenceChanged(async (user) => {
const presence = user.presence; // Update online users list
});
import { User, UserPresence } from 'chatkitty';

kitty.onUserPresenceChanged(async (user: User) => {
const presence: UserPresence = user.presence; // Update online users list
});

See also