Skip to main content

joinRoom(options)

Call this method to join the Chat Room. This method can be used to automatically join the user to the chat room.

JavaScript

sdk.joinRoom({
username,
roomPassword,
accessToken: accessToken,
email,
password
});

joinRoom Options

You can join a chat room using one of the following parameters:

  1. username
  2. accessToken
  3. email

username

Just specify any username and join the user. The username does not have to be unique.

accessToken

You can generate the accessToken for the user via the REST API. You can learn about creating an accessToken token from here..

Email

When you create a moderator from the dashboard, it gives you an email and password for the moderator, you can use the email and password fields to specify the email and password for the moderator.

You can also use the accessToken to login the moderator, learn about creating a moderator via the API here..

Parameter NameDescriptionTypeRequired
usernameUsername of the chat userStringRequired when accessToken or email is not specified
roomPasswordPassword of the room, if the room is password protectedStringRequired when the room is password protected
accessTokenAccess token of the chat room.StringRequired when username or email is not specified
emailemail of the chat userStringRequired when username or accessToken is not specified
passwordpassword to enter the user as a ModeratorStringRequired when you want the user to be a Moderator, if you are using email to login the user

Specifying Profile Picture and Custom Metadata for the user

To specify profile picture and custom metadata for the user, you can use the Create User API to generate the accessToken and login the user. The Create User API allows you to specify externalUserId, meta and profilePic URL.