Setting User Attributes on an Author

Learn about user attributes and how to apply them to an author

User attributes, also referred to as profile properties and custom properties, are a set of key/value pairs that are specific to your application domain. The system stores these key/value pairs under the properties field of an appUser. The attributes may have values of type Number, String, or Boolean.

The system limits user attributes to 4KB per user -- each key limited to 100B and each value limited to 800B. Exceeding characters are truncated. The system returns an error if an appUser the sum of all custom attributes exceeds the 4KB limit while an appUser is in the process of being created or updated.

We strongly recommend setting user attributes on a Modern Chat app user as soon as the user initiates an authenticated chat session. See the End-user Authentication section for details.

Key attributes to set include first name, last name, and email address.

📘

Currently, the Modern Chat SDK supports setting unencrypted attributes. Setting encrypted attributes is planned in a future update.

updateUser adds a set of defined and custom attributes/metadata to the user's basic profile information. Custom attributes and unstructured data are added in a flat properties object. updateUser is additive, meaning that any fields in the request body and JSON subfields in the properties field are added or overridden, but never deleted.

This JavaScript example adds the user's first name, email, and avatar.

<script>
window.addEventListener('khorosFirstMessageChatInitiated', function(event) {
          event.detail.sdk.updateUser({
              givenName: "Jane",
              email: "[email protected]",
              properties: {
                  authorAvatarUrl: "https://community.khoros.com/t5/image/serverpage/avatar-name/knitting/avatar-theme/2delicious/avatar-collection/hobbies/avatar-display-size/message/version/2?xdesc=1.0",
              }
            });
         });
</script>

Argument

Description

givenName

(optional) The user’s given name (first name).

surname

(optional) The user’s surname (last name).

email

(optional) The user’s email address.

signedUpAt

(optional) The date at which the user signed up.

Must be ISO 8601 time format (YYYY-MM-DDThh:mm:ss.sssZ).

properties

(optional) A flat object containing custom-defined user properties in key/value pairs. Supported data types: Number, String, Boolean.

Profile properties are limited to 4KB per user. Each profile property key is limited to 100B and each profile property value is limited to 800B. Exceeding characters will be truncated. If the sum total of an app user's custom properties exceeds 4KB, an error is thrown.

The JSON in properties can NOT be more than one level deep. Here are some examples:

Valid Example:

properties: {
              authorAvatarUrl: "https://community.khoros.com/t5/image/serverpage/avatar-name/knitting/avatar-theme/2delicious/avatar-collection/hobbies/avatar-display-size/message/version/2?xdesc=1.0",
              itemsInShoppingCart: 10
            }

Invalid Example:

properties: {
              address: {
                         street: "123 Main Street", 
                         city: "Austin", 
                         state: "tx"
              }, 
              itemsInShoppingCart: 10
            }

Did this page help you?