Skip to content
  • Light
  • Dark
  • Auto

Questions and Answers

In what order should the methods be called to initialize the widget?

Section titled “In what order should the methods be called to initialize the widget?”

Order:

BEFORE run() — all setters and event subscriptions

window.vivo_api.setUserToken(token);
window.vivo_api.setRegion('en');
window.vivo_api.setContactInfo({ name, phone, email });
window.vivo_api.onWidgetReady(() => { ... });
window.vivo_api.onOpenStateChange((isOpen) => { ... });
window.vivo_api.onUnreadCountChange((n) => { ... });
window.vivo_api.onError(({ message, source }) => { ... });

Launch

window.vivo_api.run({ withIcon: true }); // withIcon: true - display the widget icon

AFTER run() — window control

await window.vivo_api.open();
window.vivo_api.close();
window.vivo_api.destroy(); // when leaving the page / the widget is no longer needed

How does setRegion work? When the application locale (for example, “en”) is passed to it, the Vivo application is not translated into English on launch.

Section titled “How does setRegion work? When the application locale (for example, “en”) is passed to it, the Vivo application is not translated into English on launch.”

Currently the widget language is determined by the channel setting in the VivoChat admin panel. setRegion allows routing a conversation to the selected channel, see more in “Conversation Routing”

How can we find out exactly when the Vivo application has loaded after calling run(), so that we can show a preloader or allow the widget to be opened? Until the application has loaded, calls to vivo_api.open() do not work.

Section titled “How can we find out exactly when the Vivo application has loaded after calling run(), so that we can show a preloader or allow the widget to be opened? Until the application has loaded, calls to vivo_api.open() do not work.”

onWidgetReady will execute the callback passed to it when the widget is ready.

Is it possible to specify a flag in run() so that the application launches immediately in “open” mode?

Section titled “Is it possible to specify a flag in run() so that the application launches immediately in “open” mode?”

To make the application launch immediately in “open” mode, you need to call open() inside the callback passed to onWidgetReady

Can methods be called after run(); to change the data?

Section titled “Can methods be called after run(); to change the data?”

To update the data, you need to “remove” the widget after the end user’s target action and reinitialize the widget with the updated information The correct call order:

run(); // widget initialization
destroy(); // widget removal