Docs Pricing

Roomlio API

API METHODS

Roomlio provides you with API methods that allow you to configure your rooms, pass in your user information, and more.

rml('config')

Use this to configure your Roomlio room. rml('config') must be called prior to rml('register'). This api call allows you to dynamically set configuration for widget. If values not set here, we use the settings from the Roomlio App for the widget called by the embed code. Reasons you may want to set the configuration values dynamically would be to support multiple languages, change labels programatically and anything else you want to customize with code.

rml('config', {
  pk: '<your pk here>', // REQUIRED
  roomElementID: 'rml-room-1', // REQUIRED
  widgetID: '<your widgetID here>',
  options: {
    chipOnlineLabel: 'Question? Chat with us live now.', // for sidebar only
    chipOfflineLabel: 'Question? Contact us.', // for sidebar only
    embedPosition: 'inline', // 'inline' or 'sidebar'
    greetingMessageUsername: 'Support Team',
    greetingMessage:
      'Welcome to Example. :wave: Type a message below if you have any questions!',
    offlineMessage: "Sorry we're not available at the moment.",
    offlineContactEmail: '<your email address>',
  },
});

NOTE: Must be called before you call rml('register') or rml('registerSecure').

rml('register)

Registers the user and room. Must be called after a rml('config'). All "options" are optional for register. See the Embed Code tab via the "Get Embed Code" link for the appropriate widget on the Settings page for different combinations. If you just provide a username, we will display that for user name. If you provide first/last name as well, we will use that for display name instead. If roomKey/roomName is left off, we will name the room after the geo location of the user. Again, it is best to refer to the Embed Code tab for the widget on the Settings page for all the different combinations.

rml('register', {
  roomElementID: 'your-div-id-to-replace-with-embedded-room',
  options: {
    // All options are "optional" for `register`. See https://app.roomlio.dev/#/settings for different combinations
    userID: 'abc1234',
    username: 'jsmith99',
    first: 'John',
    last: 'Smith',
    roomKey: 'kraken1234',
    roomName: 'Kraken-Hockey',
    traits: {
      color: 'purple',
      account: 'acct1234',
      plan: 'pro',
      email: 'jsmith@example.com',
    },
  },
});

rml('open')

Open the room. Only useful if you use embedPosition: 'sidebar'.
rml('open', {
  roomElementID: 'rml-room-1', // id of room you want to open
});

rml('close')

Close the room. Only useful if you use embedPosition: 'sidebar'.
rml('close', {
  roomElementID: 'rml-room-1', // id of room you want to close
});



API EVENTS

rml-event

Roomlio will emit a rml-event event when certain actions relating to a room occur that will aid you in integrating a room into your website. You just have to add an event listener and listen for what type of event it is (see below).
// Example of how to listen for the rml-event
document.addEventListener('rml-event', (event) => {
  switch (event.detail.type) {
    case 'rml_opened':
      // Do something...
      break;
    case 'rml_closed':
      // Do something...
      break;
    case 'rml_state_change':
      // Do something...
      break;
    case 'rml_new_msg':
      // Do something...
      break;
    case 'rml_new_focus':
      // Do something...
      break;
  }
});