Widget JavaScript API

Complete reference with interactive examples

Widget Embed (ES Module)

Add the widget to your website with a single ES module import:

<script type="module">
  import SynaplanWidget from 'https://web.synaplan.com/widget.js'

  SynaplanWidget.init({
    widgetId: 'YOUR_WIDGET_ID',
    primaryColor: '#007bff'
  })
</script>

Replace YOUR_WIDGET_ID with the widget ID from your Synaplan dashboard (e.g. wdg_095ab...).

Configuration Options

Option Type Default Description
widgetIdstringrequiredWidget ID from dashboard
positionstring'bottom-right'bottom-right, bottom-left, top-right, top-left
primaryColorstring'#007bff'Primary brand color (hex)
iconColorstring'#ffffff'Button icon color
buttonIconstring'chat'chat, headset, help, robot, message, support
buttonIconUrlstringCustom icon URL (overrides buttonIcon)
defaultThemestring'light'light or dark
detectThemebooleanfalseAuto-detect host page theme
autoOpenbooleanfalseOpen chat on page load
autoMessagestring'Hello! How can I help you today?'Greeting message
widgetTitlestring'Chat Support'Chat header title
messageLimitnumber50Max messages per session
allowFileUploadbooleanfalseEnable file uploads
fileUploadLimitnumber3Max files per message
maxFileSizenumber10Max file size (MB)
lazybooleantrueLazy-load UI on first click
fullscreenModebooleanfalseStart in fullscreen
allowFullscreenbooleanfalseAllow fullscreen toggle
hideButtonbooleanfalseHide button (API control only)
apiUrlstringautoOverride API URL
externalUserIdstringExternal user ID
privacyPolicyUrlstringPrivacy policy link
allowedDomainsstring[][]Restrict to specific domains

JavaScript API Methods

Method Description
SynaplanWidget.init(config)Initialize the widget with configuration
SynaplanWidget.open()Open the chat panel
SynaplanWidget.close()Close the chat panel
SynaplanWidget.startNewChat()Start a new conversation
SynaplanWidget.destroy()Remove the widget from the page

Example: Full Configuration

<script type="module">
  import SynaplanWidget from 'https://web.synaplan.com/widget.js'

  SynaplanWidget.init({
    widgetId: 'wdg_095ab093966991158f9957f42ae8b4f2',
    position: 'bottom-right',
    primaryColor: '#13224e',
    iconColor: '#ffffff',
    defaultTheme: 'light',
    autoOpen: false,
    autoMessage: 'Hi! How can I help?',
    messageLimit: 50,
    allowFileUpload: true,
    fileUploadLimit: 3,
    maxFileSize: 10,
    lazy: true
  })
</script>

Example: Programmatic Control

<script type="module">
  import SynaplanWidget from 'https://web.synaplan.com/widget.js'

  SynaplanWidget.init({
    widgetId: 'wdg_...',
    hideButton: true
  })

  // Open chat via your own button
  document.getElementById('my-chat-btn')
    .addEventListener('click', () => SynaplanWidget.open())
</script>