Advanced Closer widget integration

The basic method for starting the widget by calling the closer.init method with the orgId parameter can be extended with additional attributes:

apiKey - enables opening the widget from the client's apiKey, thanks to which we can restore his session. The value is UUID, e.g. "00000000-0000-0000-0000-000000000000"

closer.init({
orgId: "00000000-0000-0000-0000-000000000000",
apiKey: "00000000-0000-0000-0000-000000000000"
});

onOpen - triggers the function given as an attribute every time the widget is opened.

closer.init({
orgId: "00000000-0000-0000-0000-000000000000",
onOpen: () => { console.log("widget opened") }
});

onClose - triggers the function given as an attribute each time the widget is closed.

closer.init({
orgId: "00000000-0000-0000-0000-000000000000",
onClose: () => { console.log("widget closed") }
});

onMessageSent - triggers the function given as an attribute every time the client sends a message.

closer.init({
orgId: "00000000-0000-0000-0000-000000000000",
onMessageSent: () => { console.log("client sent message") }
});

getLoginHintToken (optional) - it will trigger function given as na attribute when client authorization with oauth is needed. Function must return Promise<string>.

closer.init({
orgId: "00000000-0000-0000-0000-000000000000",
getLoginHintToken: () => Promise.resolve("myLoginHintToken")
});

Use the closer.deinit method to log off the client securely. It accepts no arguments. It removes the client's data from the browser and removes the widget from the DOM. After calling this method, we can use closer.init again.

closer.deinit();