Connect your user base using the RumbleTalk Chat Room JS SDK


If you have your own users base and wish to connect it to your RumbleTalk Chat,
you may use the below API instructions to set it up.

What can you do with the JS SDK ?

  1. With the RumbleTalk JS SDK, your users will be able to login to the chat manually.
  2. With the RumbleTalk JS SDK you can set that only registered users in your users base will be able to automatically login to the chat room(with manual intervention).
  3. RumbleTalk REST API can be used for more advanced options should be needed.
  4. WordPress website owners do not need to use the instructions on this page, the RumbleTalk chat room plugin is pre-integrated already, so all you need to do is download the WordPress chat plugin and set it according to the instructions.


Administrator - prevent the regular login option


  1. Log-in to your administrator panel
  2. Go to your chat Settings
  3. Click on the Login tab
  4. At the bottom of the page, check the "Automatic login (using your own users base) - removes the login interface" option under "Advance"
Using RumbleTalk API - sdk to auto login to the chat


Administrator - Set your user preferences.


LOGIN TYPE: You will need to choose, at least, one type of login option to make the auto login work.

  • "Guest (anonymous)" - Using your user base as a nick name only.
  • "RumbleTalk (Members and admins)" - Using your user base combined with predefined users in RumbleTalk.

MODERATOR: creating an admin for your chat requires.

  1. Create a chat room moderator in RumbleTalk users base, make sure the exact Nickname defined is also set in your own users base.
  2. When the system will try to logs you in via the SDK, they will ask admins to provide a password for the first time (cookie saved).

EXTRA: Two options that you need to know.

  • Allow Guests Login - If your users are not imported into the RumbleTalk users base, make sure that the "Allow Guests Login" is checked.
  • View the conversation - If you want that anyone can see the conversation while only registered users will be able to actually talk, make sure that the "Allow Viewers" is checked.

What to do on your end?


First, add the following code to the page with the chat in your website. Preferably at the <head> section.

<script type="text/javascript">
(function(g,v,w,d,s,a,b){w['rumbleTalkMessageQueueName']=g;w[g]=w[g]||
function(){(w[g].q=w[g].q||[]).push(arguments)};a=d.createElement(s);
b=d.getElementsByTagName(s)[0];a.async=1;
a.src='https://d1pfint8izqszg.cloudfront.net/api/'+v+'/sdk.js';
b.parentNode.insertBefore(a,b);})('rtmq','v0.37',window,document,'script');
</script>

Secondly, get your chat hash code as shown in the image below (highlighted in yellow):

RumbleTalk hash code for integrating with SDK

Then add the following code when a user has been authenticated. This means you will need to dynamically populate this fields from your users base.

<script type="text/javascript">
rtmq(
    'login',
    {
        hash: 'YOUR_CHAT_HASH',
        username: 'USERNAME',
        password: 'PASSWORD'
    }
);
</script>
  1. YOUR_CHAT_HASH - 8 characters code, representing your chat (see the image above; it can be found in the dashboard)
  2. USERNAME - The nickname of the user. * This field should be changed based on the authenticated user.
  3. PASSWORD [optional] - The predefined password. * If you're using the "Guest" option, this field is optional



YOU ARE DONE!!!




ADVANCED OPTION - Logout

Chat owner can now initiate logout of users using the Login SDK. To do so, call the following function:

<script type="text/javascript">
rtmq(
    'logout',
    {
        userId: 'USERS_ID', // [optional]
        username: 'USERS_NAME' // [optional]
    }
);
</script>

The [optional] parameters "USERS_ID" and "USERS_ID" are optional and used only to validate that the correct user is being logged out. They can be used separately or together. Excluding them will remove the connected user (who's browser called the function) regardless of their "user id" and\or "username"

ADVANCED OPTION - Logout CallBack

Chat owners can now also listen to the event of a user logout. To do so, call the following function:

<script type="text/javascript">
// necessary settings for callback function
rtmq(
    'config',
    {
        usePostMessage: true
    }
);

// set the callback function
rtmq(
    'logoutCB',
    {
        callback: CALLBACK_FUNCTION
    }
);
</script>

The "CALLBACK_FUNCTION" will be called with a "reason" variable when the user logs out of the chat. An example of the callback function is such:"

function (reason) {
    console.log(reason);
    // code to execute on logout
}

currently, the following values are possible for the reason variable:

  • "button_clicked" - the user clicked on the logout button
  • "sdk_request" - the "logout" function of the SDK was called
  • "unknown" - the user disconnected from the chat for an unknown reason (such as network connectivity problems)


TROUBLESHOOTING

Q: All seems to be okay for windows os browsers, but for mac users, none of the users are able to login. each browsers throwing the errors.

A: Please make sure to use the latest SDK, version 0.37 or up. (update it in the code you added to your pages).


Q: If I open the window in multiple browsers, multiple user instances are created. What is the reason?

A: It's intended. That is the way the Guest login option works. "anonymously" You can move the RumbleTalk login option (username + password); which is also more secure. It uses our RESTful API to create and manage the users on RumbleTalk as well. This option requires programming, but creates a much more controllable chat.


Q: Can't create autologin for chatrooms using the RumbleTalk JS SDK.

A: The main reason why the automatic login is not working is that the "Allow guest logins" option is disabled for the chat rooms.

If you use the "Allow RumbleTalk login" only, you'll need to do one of the following:
1. Manually add each of your users
2. Use our RESTful API to automate the creation \ update of your users.
The first solution (allow guest logins) is MUCH simpler.


Q: I am using Chromium browser, it seems not to allow auto login.

A: We do not support Chromium browser, sorry.


Q: Any way to show the corresponding avatar from the forced SDK?

A: The force SDK will use the default avatar. To use a custom avatar, you will need to use our REST API to create users with avatars.