Instance methods and events
The Webchat widget, upon initialization, exposes a collection of methods and events that you can use to interact with the widget. You can use these to control the widget's behaviour, theme the widget, send messages from your own functions and much more.
Instances
Method | Description |
---|---|
openWindow | Opens Webchat if it is currently closed. |
closeWindow | Closes Webchat if it is currently opened. |
sendMessage | Sends the specified message to the virtual assistant. |
updateContext | Updates the context of the user. |
setCSSVariables | Overrides the exposed CSS variables so the web-widget can be custom styled. |
setLocale | Updates the locale of the user. |
instance.openWindow
Opens the chat window if it is currently closed
Example
instance.closeWindow
Closes the chat window if it is currently open
Example
instance.sendMessage
This method can be used to programmaticaly send a text message to the assistant.
Example
Usage
- If a conversation already exists, the message will be sent directly to the user.
- If there is no existing conversation, the
welcome_trigger_message
will be overridden and the message will be sent. - If Visitor Information is required, the message will be sent only after the form has been completed.
note
If the chat window is closed, use the openWindow
method to open it.
Example
instance.updateContext
This method can be used to update the user information or to add new tags to the current session.
Example
instance.setLocale
This method can be used to update the default language text of the webchat. You can find a list if the supported locales (languages) in the following table.
Available locales
Code | Language |
---|---|
de | ๐ฉ๐ช German |
el | ๐ฌ๐ท Greek |
en | ๐บ๐ธ English |
es | ๐ช๐ธ Spanish |
fr | ๐ซ๐ท French |
it | ๐ฎ๐น Italian |
bg | ๐ง๐ฌ Bulgarian |
pt-br | ๐ง๐ท Portuguese (Brazil) |
ro | ๐ท๐ด Romanian |
pl | ๐ต๐ฑ Polish |
cs | ๐จ๐ฟ Czech |
id | ๐ฎ๐ฉ Indonesian |
nl | ๐ณ๐ฑ Dutch |
sr | ๐ท๐ธ Serbian |
sv | ๐ธ๐ช Swedish |
ru | ๐ท๐บ Russian |
sq | ๐ฆ๐ฑ Albanian |
zh | ๐จ๐ณ Chinese |
ar | ๐ธ๐ฆ Arabic |
ja | ๐ฏ๐ต Japanese |
tr | ๐น๐ท Turkish |
Example
instance.setCSSVariables
This method can be used to change appearance of the web-widget. You can find a list of all the available variables below
CSS variables:
Variables | Description |
---|---|
--moveo-background-color | The primary color of web widget |
--moveo-accent-color | The secondary color of the web widget |
--moveo-header-height | The height of the web widget header |
Example
Events
Event | Description |
---|---|
onSessionCreated | Is executed every time a new conversation is created |
onConversationClosed | Is executed every time a conversation is closed |
instance.onSessionCreated
You can use this event to execute your own functions when a new session is created.
instance.onConversationClosed
You can use this event to handle the cases when the conversation is closed.