Widget methods
After the script loads, the widget creates window.Parsewise with public methods for programmatic control.
METHOD
Parsewise.open(message?)
Opens the chat drawer. If a string is passed, it is automatically sent as the first user message.
// Just open the chat
window.Parsewise.open()
// Open and send a starter message
window.Parsewise.open('Помогите подобрать ноутбук до 80 000 ₽')
METHOD
Parsewise.close()
Closes the open chat. Has no effect if the chat was not open.
window.Parsewise.close()
METHOD
Parsewise.destroy()
Fully removes the widget from the page: detaches scroll listeners, removes the CTA button and the Shadow DOM. After the call window.Parsewise is no longer usable.
window.Parsewise.destroy()
Example: Ask AI button
<button id="ask-ai">Спросить AI</button>
<script>
document.getElementById('ask-ai').addEventListener('click', () => {
window.Parsewise?.open('Какие у вас есть ноутбуки для работы?')
})
</script>
window.Parsewise is created asynchronously — after the script loads. Always check for the object before calling methods.
SPA / React / Next.js
In an SPA, wait for the widget to be ready. The simplest way is polling window.Parsewise:export function openParsewise(message?: string) {
const tryOpen = () => {
if (window.Parsewise) {
window.Parsewise.open(message)
} else {
setTimeout(tryOpen, 100)
}
}
tryOpen()
}