#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
srcafter 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
| Parameter | Default value | Possible values |
|---|---|---|
| locale - interface language | en | en, ru |
| auth_provider - default authorization provider | email - 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 | #93BEE6 | HEX color code |
| telegram_link - link to the Telegram channel | not set | link to Telegram, if not set, the Telegram option is not displayed in the widget |
| open - whether to open the widget right away | false | true - open the widget right away, false - display only the button |
| fullscreen - expand the widget to full screen without the ability to minimize | false | true - expand to full screen, false - show as a minimizable window |
| page - widget's starting page | not set | chats - 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) | false | true - 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.2 | false | true - 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. |