window.OTHEGO API
Open, close, and send messages to the widget from your own JavaScript.
Availability
After the widget script loads, Othego exposes window.OTHEGO with helpers to control the chat UI from your site — for example, a "Chat with us" button or a support link that pre-fills a question.
Wait until the widget script has loaded before calling window.OTHEGO. If you call it too early, the object may be undefined.
Methods
- OTHEGO.open() — opens the chat panel.
- OTHEGO.close() — closes the chat panel.
- OTHEGO.toggle() — opens if closed, closes if open.
- OTHEGO.setMessage(text) — opens the panel and sends text as the user's message (starts a conversation turn).
Examples
<button type="button" onclick="window.OTHEGO?.open()">
Chat with us
</button>document.getElementById("pricing-help").addEventListener("click", () => {
window.OTHEGO?.setMessage("What is included in the Pro plan?");
});function whenOthegoReady(callback) {
if (window.OTHEGO) {
callback(window.OTHEGO);
return;
}
const interval = setInterval(() => {
if (window.OTHEGO) {
clearInterval(interval);
callback(window.OTHEGO);
}
}, 200);
}
whenOthegoReady((api) => api.open());Configuration object
Set window.OthegoConfig before loading chatbot.js. chatbotId is required; chatbotSlug is recommended so the widget resolves the correct public config.
window.OthegoConfig = {
chatbotId: "507f1f77bcf86cd799439011",
chatbotSlug: "my-support-bot"
};