Methods
The Chathive JavaScript SDK provides an JavaScript object with a few methods. These allow you to interact with the widget and customize it's behaviour
Widget
Chathive.widget.init
The primairy use-case of the SDK is to show the Chathive widget on your website. This can be done by calling the init method. By default we will immediately show the widget trigger on your website if you don't want this you can provide the hide attribute to hide the widget by default.
see more init options in the attributes section.
Chathive.widget.embed
Instead of showing a widget on your screen, this method will embed your widget into your app.
see more init options in the attributes section.
Chathive.widget.isWidgetLoaded
Check if the widget has been initialised and is ready to be used. This will return a boolean
Chathive.widget.open
This will open the widget, if the widget was hidden it will be shown.
If you want to keep the widget hidden, set show attribute to false.
Chathive.widget.close
This will close the widget and keep the trigger visible.
If you also want to hide the widget set hide attribute to true.
Chathive.widget.hide
Hide the widget from your website
Chathive.widget.isHidden
Check if the widget is hidden. This will return a boolean
Chathive.widget.show
Show the widget on your website
Chathive.widget.destroy
Remove the widget from your website. f you want to re-enable the widget you need to recall the init method.
Messages
Chathive.widget.sendMessage
Send a message as the website visitor.
Language
Chathive.widget.getCurrentLanguage
Get the current language that is used in the widget. By default we will use the language that is marked as default in your dashboard
Chathive.widget.setLanguage
Set or change the language of the widget. We support all ISO 639-1 language codes.
Notifications
Chathive.widget.disableNotifications
Don't get notifications when the widget is closed. Is usefull on mobile devices
Chathive.widget.enableNotifications
Allow notifications to be shown when widget is closed.
Context
Chathive.widget.getContext
Get the current context of the conversation
Chathive.widget.setContextFields
Set or update a new key in the conversation context.
If you set a value to undefined
this key will be removed from the context
Customer data
Chathive.widget.getCustomerData
Get the data from the current customer
Chathive.widget.updateCustomerData
Set or update the customer data for the current session. This will help you to identify the customer behind a conversation
More info about customerData
Last updated