Our PLuG widget SDK is a powerful tool designed to further enhance our widget on your website or application. With our SDK, you can seamlessly integrate our feature-rich widget by empowering you to create a dynamic and personalized user experience. Let’s get started.
Method | Description |
---|---|
plugSDK.init() | Initialize the PLuG widget. |
plugSDK.shutdown() | End the user session which is currently initialized in PLuG widget. |
plugSDK.toggleWidget() | Open/close the widget. |
plugSDK.onEvent() | Perform specific actions based on the payload type received from the PLuG widget. |
plugSDK.toggleTheme('light/dark') | Toggle PLuG widget theme. |
plugSDK.toggleWidget(true, 'create_conversation', {startConversationContent: 'Hi',}); | Start a conversation. |
Initialize the widget
Calling the init()
method initializes the PLuG widget on your website. Initializing the PLuG widget is necessary for you to perform any other actions on the PLuG widget SDK.
When React is using Strict
mode, you might get a warning message from window.plugSDK.init()
being called multiple times. These errors won’t impact the installation and functioning of the widget.
Shutdown the widget
The shutdown()
method is helpful when you want to end the user session which is currently initialized in the PLuG widget. You can use this method to clear your users’ conversations and tickets when they log out of your application.
After calling the shutdown()
method, you can call the init()
method to reinitialize PLuG widget on your website if you wish to showcase the PLuG widget again in the logged out version of your application.
Once the shutdown()
method is called, all the other functionality in the widget such as session recording or Nudges is also be stopped. You need to reinitialize the widget again to have these features active.
Open or close the widget
To control whether the PLuG widget launcher screen is open, you can use the togglewidget()
method with a boolean value. Your code needs to listen to the event ON_PLUG_WIDGET_READY
to call this method. If the widget isn’t ready then this method won’t make any action.
Take actions from events
This method can be used to listen to events coming from the PLuG widget. The following are the different PAYLOAD_TYPES
.
Event | Meaning |
---|---|
ON_PLUG_WIDGET_CLOSED | The PLuG widget is closed. |
ON_PLUG_WIDGET_OPENED | The PLuG widget is opened. |
ON_PLUG_WIDGET_READY | The PLuG widget is ready. |
ON_PLUG_WIDGET_UNREAD_COUNT_CHANGE | The user receives a new message to their PLuG. You can also listen to the number of unread messages and display that to your user. |
Toggle theme
The toggle theme method allows you to dynamically modify the PLuG SDK’s theme, even after initializing the PLuG widget. This functionality enables real-time adjustments to the PLuG widget’s theme based on diverse themes preferred by your users.
The method accepts two inputs: light
and dark
.
The parameter is optional; calling toggleTheme()
toggles the current theme, and specifying a theme as a parameter allows toggling for that specific theme.
Start conversation
This method is utilized to open the PLuG widget with the conversation creation view activated. It essentially replicates the action of clicking the Send us a message button, launching the widget directly to the conversation initiation screen.
The method also accepts an optional input parameter, allowing you to pre-fill a message in the conversation creation screen. This provides your users with a prompt to initiate a conversation with your team.
Looking for something more? Reach out to us through our own PLuG widget in the bottom right of this screen and we would be happy to assist you.