TalkJS allows different groups of users to have different settings by assigning them a 'role'. You have full control over which user gets which role.

For example, you may want a set of your users to be able receive SMS notifications if they have a new message. Or you may want some users to be able to share files. You can do all of this using roles.

A role allows you to define the following settings for a group of users:

  • Allow/disallow file or location sharing
  • Create custom email notification templates
  • Configure SMS settings
  • Configure text/contact information surpression
  • Configure how links in chat messages wll be opened
  • Customize the standard TalkJS user interface using themes

You can create roles from the TalkJS dashboard.

How to create and use a role

1. Add a role in the dashboard

To add a role, click on roles at the top left corner of your dashboard.

Next, click on the "+" tab and input the role name. You can decide if the role will copy data from previous roles or use the default role setting.

After this, you can choose the settings for the role by using the checkboxes next to each setting.

2. Assign a role to a user

You assign a role to a user when you create the user. For example, if the name of the role you created on the dashboard is buyer, you can assign this role to the user "Alice" in your code like this:

const me = new Talk.User({
    id: "123456",
    name: "Alice",
    email: "[email protected]",
    photoUrl: "https://demo.talkjs.com/img/alice.jpg",
    welcomeMessage: "Hey there! How are you? :-)"
    role: "buyer" // <-- that's the one!
});

Make sure the role corresponds precisely to a role name you chose in the dashboard.