Realtime API

interface UserRef

References the user with a given ID.

Used in all Realtime API operations affecting that user, eg fetching/updating their data or adding them to a conversation. Created via Session​.user.

Method Overview

get

Fetch a snapshot of the user.

Properties

id
: string

The ID of the referenced user.

Immutable: if you want to reference a different user, get a new UserRef instead.

get

userRef.get(): Promise<UserSnapshot | null>
Fetch a snapshot of the user.

This contains all of a user's public information. This does not require any permissions, you can read the public information of any user. Private information such as email addresses and phone numbers are not included in the response.

Parameters

None.

Returns

Promise<UserSnapshot | null>

A snapshot of the user's public attributes, or null if the user does not exist.

interface UserSnapshot

A snapshot of a user's attributes at a given moment in time.

Users also have email addresses and phone numbers, but these are only exposed on the REST API.

Properties

custom
: Record<string, string>

Custom metadata you have set on the user

id
: string

The unqiue ID which is used to identify the user in TalkJS

locale
: string
name
: string

The user's name which will be displayed on the TalkJS UI

photoUrl
: string | null

An optional URL to a photo which will be displayed as the user's avatar

role
: string

TalkJS supports multiple sets of settings, called "roles". These allow you to change the behavior of TalkJS for different users. You have full control over which user gets which configuration.

welcomeMessage
: string | null

The default message a person sees when starting a chat with this user