Buni.aiDocs
Chatbot

Web chat widget

Embed a chatbot on your website with the chat widget, customise how it looks and behaves, and control it from your page.

Web chat The web chat widget puts your chatbot on any website: a floating chat button in the corner of the page, or a chat window embedded in the page itself. It needs no account with another provider; you create an embed token, copy a snippet and paste it into your site.

Everything for the widget is on the chatbot project's Settings›Chat Widget tab.

Add the widget to your site

Publish the chatbot

The widget talks to the published version of your chatbot. Publish the project first, and again after every change you want visitors to see.

Create an embed token

Open Settings›Chat Widget. Under Chat Widget Tokens, select Create New Token. In Allowed Domain (Optional), enter the domain the widget will run on, such as example.com. Leave it empty to allow any domain.

Create one token per website or environment, so each can be managed separately.

Customise it

Under Customization, set the widget's colours, branding, position and behaviour. Live Preview shows the result; Open in New Tab opens it full size. Select Save Config when you are done.

Copy the code

Under Chat Widget Codes, pick the tab for your site: iframe, JavaScript, React, Next.js, Vue, Angular or WordPress. The code already contains your token. Copy it.

Paste it into your site

Paste the code into every page that should show the chat, just before the closing </body> tag for the iframe and JavaScript versions. Reload the page and the chat button appears.

The Chat Widget settings tab with the Chat Widget Tokens list, the Customization accordions and the Live Preview
The Chat Widget tab: tokens, customisation and a live preview. Placeholder token shown.

Customisation

SectionSettings
Theme & ColorsTheme (System Default, Dark Mode, Light Mode), Primary Color, Secondary Color
BrandingCompany Name, Custom Logo URL, Welcome Message
Layout & BehaviorPosition (Bottom Right, Bottom Left, Top Right, Top Left, Center), Width (px), Height (px), Trigger Text, Border Radius, Default display mode (Full, Minimal, Hidden)
Avatar CustomizationAvatar Type (Icon (Chat Bubble), Image (Custom Logo), Text (Initials)), Avatar Text, Avatar Image URL

Center opens the chat as a centred modal. Leave Trigger Text empty for an icon-only chat button.

Options

OptionDefault
Auto-open on page loadOff
Start minimizedOff
Show minimize/maximizeOn
Allow minimize (widget mode)On
Allow close buttonOn
Show Buni.ai brandingOn
Enable on mobileOn
Enable file uploadsOff
Show message timestampsOn
Show trigger button textOn
Show privacy policy nuggetOff. When on, set a Privacy message and Privacy policy URL.
Show pre-chat formOff. When on, visitors fill in Pre-chat form fields (by default Name and Email) before chatting.
Show start chat buttonOff. Set its label with Start Button Text (default "Start Chat").
Hide default trigger (API mode)Off. Hide the built-in chat button when you open the chat from your own code.

Auto messages send a message after a delay (in milliseconds) when their conditions match, optionally with buttons and quick replies.

Sessions and feedback

Under Session Management:

  • Auto-end inactive sessions with an Inactivity Timeout (minutes).
  • Show feedback after session end, with thumbs, multiple-choice or text questions.
  • Allow session restart, on by default.

For satisfaction surveys across all channels, use the project's CSAT settings tab instead. See CSAT.

Control the widget from your page

JavaScript snippet

The JavaScript snippet sets window.__buni and loads the widget script:

<script>
  window.__buni = window.__buni || {};
  window.__buni.embedToken = 'YOUR_EMBED_TOKEN';
  window.__buni.theme = 'light';
  window.__buni.position = 'bottom-right';

  (function (d, s, id) {
    var js, bjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id; js.async = true;
    js.src = 'https://<your Buni.ai domain>/api/embed/widget?token=' + encodeURIComponent(window.__buni.embedToken);
    bjs.parentNode.insertBefore(js, bjs);
  }(document, 'script', 'buni-widget-js'));
</script>

Once loaded, the script exposes window.BuniAIWidget with open(), close() and toggle(), so a button on your page can open the chat:

<button onclick="window.BuniAIWidget && window.BuniAIWidget.open()">Chat with us</button>

iframe embed

The iframe code loads the chat from:

https://<your Buni.ai domain>/embed/chat?token=YOUR_EMBED_TOKEN&embedded=true

The app writes your saved settings into the URL as query parameters. The most useful ones to change by hand:

ParameterValues
themelight, dark or system
primaryColor, secondaryColorA colour, URL-encoded (%23c05c00)
companyName, welcomeMessage, triggerTextText
customAvatarAn image URL
positionbottom-right, bottom-left, top-right, top-left
defaultModefull, minimal or hidden
autoOpen, showBranding, enableFileUpload, showTimestampstrue or false

Messages between your page and the iframe

An embedded chat accepts commands from the page that contains it through postMessage. For security, it ignores everything until your page sends a handshake, and then accepts messages only from that page's origin.

const chat = document.getElementById('buni-chat').contentWindow;
const origin = 'https://<your Buni.ai domain>';

// 1. Handshake first
chat.postMessage({ type: 'buni:parent_handshake' }, origin);

// 2. Then send commands
chat.postMessage({ type: 'sendMessage', data: { message: 'I need help with my order' } }, origin);
chat.postMessage({ type: 'theme-change', data: { theme: 'dark' } }, origin);
Command (type)Effect
show, hideShow or hide the chat.
minimize, maximizeChange the chat's size.
sendMessageSend data.message as if the visitor typed it.
setCustomerData, setSessionVariablesPass details about the visitor or page into the session.
clearChat, restartSessionClear the conversation or start a new session.
theme-changeSwitch to data.theme.
destroyTear the chat down.

The chat posts events back to your page, including ready, visibility_changed, minimized, maximized, new_message and chat_cleared. Listen with window.addEventListener('message', ...) and check event.origin.

Framework packages

The React, Next.js, Vue and Angular tabs generate code for the @buni.ai/chatbot-react, @buni.ai/chatbot-vue and @buni.ai/chatbot-angular packages. Install the package for your framework and paste the generated component. The WordPress tab generates a snippet for your theme.

Answers that appear as they're written

When an AI node answers in the chat, the customer sees the answer grow as the model writes it, in one message that the finished answer then replaces. This happens when:

  • the node's answer goes to the customer as written: it's the last node in its branch, and has no tools, exit conditions, UI components, response template or integration triggers, with text output;
  • the node uses OpenAI, Anthropic, Google, Groq or Mistral.

Any other answer arrives whole, as before, while the chat shows the typing indicator. An answer that starts like JSON or code also arrives whole, because the bot reshapes it before sending it. Republish the chatbot to turn this on.

Voice notes

When the project answers voice notes, the chat shows a microphone button in place of send while the message box is empty. The customer records a note of up to 5 minutes, and the bot transcribes it and answers it like a typed message. If you embed the chat in your own iframe, add allow="microphone" to it; the snippets here already include it.

Live voice

When the project offers live voice conversations, the chat shows a Talk button beside the microphone while the message box is empty. The customer talks with the bot out loud, hears each answer, and sees the conversation as text in the chat. Live voice uses your plan's voice minutes. The iframe needs allow="microphone", as for voice notes.

Troubleshooting

Last reviewed 24 September 2026

On this page