Developer docs menu

Building

AI assistant on your site

Put a business’s AI assistant on a website, listen for what visitors do in it, and pick its inquiries and bookings out of the webhooks.

A business builds its AI assistant in the dashboard, under AI assistant. What it knows, how it talks and whether it books are the owner’s settings, and there is no API to change them. A website you build for a business needs only the embed code, and can listen for what visitors do.

The embed code

Copy it from Chat Studio, on the Install tab, and put it once before the closing body tag of every page that should show the assistant:

<script src="https://bookingmachine.io/chat-embed.js" data-business="your-business" async></script>
AttributeWhat it does
data-businessRequired. The last part of the business’s booking page address.
data-chatbotWhich assistant, when the business has more than one. Chat Studio adds it to the code for you.

Tag managers and some site builders drop data- attributes, so both can go on the address instead: chat-embed.js?business=your-business&chatbot=main. The attributes win when both are given.

  • The loader is small. It asks whether the assistant is on first, and loads the chat itself only when it is. A business that has switched it off costs a visitor one request and shows nothing.

  • The chat draws in its own shadow root, so your styles do not reach it and its styles do not reach your page. It sits in a corner of the window, above everything else.

  • Adding the code twice shows one chat, not two.

  • A strict content security policy needs the BookingMachine address in script-src and connect-src.

Info: Under Where it may run, the owner can list the websites the assistant may answer on. Anywhere else, the chat does not open. The business’s own BookingMachine website and booking page always work.

Browser events

The chat sends these events on the page, and they bubble up to the document. Each carries the business in its detail. Nothing is sent from the owner’s preview.

EventWhen
bookkit:chat-openedA visitor opens the chat.
bookkit:chat-leadA visitor sends their details from the inquiry form.
bookkit:chat-bookingA visitor books in the chat.
document.addEventListener('bookkit:chat-booking', (event) => {
  // event.detail.business is the business's booking page name
  gtag('event', 'chatBooking', { business: event.detail.business })
})

Webhooks

Inquiries and bookings from the chat arrive as the usual webhook events, with where they came from:

EventFieldValue
lead.captureddata.lead.sourcechat
booking.createddata.booking.sourcechat

Conversations themselves are not sent anywhere and are not in the API. The owner reads them in Chat Studio, and they are deleted after the time the owner chose.

Still have questions? Contact support