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({
uniqueUserIdentifier: uniqueUserIdentifier,
username,
roomPassword,
accessToken: accessToken,
email,
password
});

joinRoom Options

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

  1. uniqueUserIdentifier
  2. accessToken
  3. username (not recommended)
  4. email together with password (not recommended)
roomPassword only applies to the username option

roomPassword is sent to the chat room only when you join with username. If you join with uniqueUserIdentifier, accessToken, or email and password, any roomPassword you pass is ignored. For a password-protected room, either join with username, or let the join screen ask for the room password.

username

Just specify any username and join the user. The username does not have to be unique. This method is not recommended use the uniqueUserIdentifier instead.

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. This method is not recommended, use the accessToken instead, read the guide to learn more. Migrating to New Join Modal

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

Parameter NameDescriptionTypeRequired
uniqueUserIdentifierUnique User Identifier of the chat userStringRequired when accessToken or email is not specified
username | Username of the chat user (not recommended, use `uniqueUserIdentifier` or `accessToken` instead) | String | Required when accessToken or email is not specified |
roomPassword | Password of the room, if the room is password protected. **Only honoured when joining with `username`** — ignored with `uniqueUserIdentifier`, `accessToken`, or `email` | String | Required when the room is password protected and you are joining with `username` |

accessToken | Access token of the chat room. | String | Required when username or email is not specified | email | email of the chat user. Must be sent together with passwordemail on its own is rejected with invalid parameters | String | Required when username or accessToken is not specified | password | password to enter the user as a Moderator | String | Required 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.