#1108: Widget initialization parameters

Отредактирована: 153 дня назад

Symptoms

What are the parameters for initializing the widget and in what sequence are they applied?

Solution

Embedded widgets in Swarmica can be customized to match the desired user experience in the application where the widget is embedded.

Application order

Settings for parameters are applied according to the following logic:

  • User settings that he/she has set in their Swarmica profile (for example, language).
  • Parameters passed in the embed URL (see example below, values in src after the ? sign).
  • Settings set by the Swarmica administrator in the settings of the corresponding channel.
  • Default settings.

Example of widget embedding code:

<!-- start embedded Swarmica widget script -->
  <iframe src="https://your.swarmica.domain/widgets/index.html?id=123qwe&locale=ru&auth_provider=email&button_color=%23dc0d1d&telegram_link=https%253A%252F%252Ft.me%252Fswarmica&open=true&page=new_chat" id="123qwe" style="position: fixed; right: 12px; bottom: 12px; width: 56px; height: 56px; overflow: hidden; "
    allowTransparency="true"
    frameborder="0"
    allowTransparency="true" frameborder="0"></iframe>
  <script src="https://your.swarmica.domain/widgets/render.js"></script>
  <script>
    const iframe = document.getElementById("123qwe")
    iframe.onload = () => {
      renderWidget("123qwe")
    }
  </script>
  <!-- end embedded Swarmica widget scripts -->

Available parameters

ParameterDefault valuePossible values
locale - interface languageenen, ru
auth_provider - default authorization provideremailemail - authorization by email + password, code - authorization by OTP code, for this option, you must also pass the otpdata parameter, anonymous - no authorization
button_color - color of the widget opening button#93BEE6HEX color code
telegram_link - link to the Telegram channelnot setlink to Telegram, if not set, the Telegram option is not displayed in the widget
open - whether to open the widget right awayfalsetrue - open the widget right away, false - display only the button
fullscreen - expand the widget to full screen without the ability to minimizefalsetrue - expand to full screen, false - show as a minimizable window
page - widget's starting pagenot setchats - list of chats, last_chat - last open chat, new_chat - new chat. If not set, then the first page is the app selection inside the widget
allow_logout - show the logout button or not (appeared in version v5.7.1)falsetrue - show the button and allow logging out of the account, false - do not show the logout button (logging out of the account is still possible programmatically)
logout_on_init - log out of the account when initializing the widget, appeared in version v5.9.2falsetrue - log out of the account during initialization, this value may be useful if in your app the user logs in under different accounts in the Swarmica widget within the same session via otpdata, false - do not log out.