Explained

Embed JavaScript reference

Control booking and live chat on your website with JavaScript: several embeds on one page, events, and opening or closing them from your code.

5 min readBooking websiteUpdated November 29, 2026
Open in the app

This guide is for whoever builds your website. The code from Settings › Appearance › Embed covers most websites without writing JavaScript. Use the functions below when you need more, for example to track bookings in your analytics or open the booking from your own code.

Replace https://hairhaven.onsoftalon.com with your booking site's address, as shown in the code from Embed.

Booking

The script adds window.$softalon.booking:

<script src="https://hairhaven.onsoftalon.com/embeds/booking.js"></script>

Options

Every option from Booking embed options explained has a JavaScript name. As data- attributes, the same names are written with dashes, so serviceId becomes data-service-id.

OptionValue
urlYour booking site. Defaults to the site the script is loaded from.
variantsheet (side panel, default) or dialog (full screen), for popups
heightauto (default) or a CSS height like 700px, for inline embeds
languageOne of your additional languages, like de
themelight, dark or system
accentColorA hex color like #E11D48
hideHeader, hideHeadingtrue hides them
locationId, serviceId, memberIdPreselect a location, service or member
firstName, lastName, emailAddress, phoneNumber, notesFill in client details ahead

Functions

FunctionWhat it does
init(options)Sets the options of the page-wide popup, the one that open() and buttons without an id open
open(options) and close()Opens or closes the popup. Options passed to open apply to that opening only.
isOpen()Tells you whether a popup is open
create(options)Creates a popup with its own options and returns it. With an id, buttons with data-softalon-booking-trigger set to that id open it.
inline(target, options)Puts an inline booking inside an element or CSS selector, and returns it
floatingButton(options)Adds a floating button. Takes text, color and position (right or left) besides the other options.
get(id)Returns the embed created with that id
on(event, callback) and off(event, callback)Listens to the events of every booking embed on the page

What create, inline and floatingButton return has its own open, close, isOpen, on, off and destroy, which removes that embed.

<div id="booking"></div>
<button data-softalon-booking-trigger="coloring">Book coloring</button>

<script>
    window.$softalon.booking.inline("#booking", { locationId: "LOCATION_ID", height: "700px" });
    window.$softalon.booking.create({ id: "coloring", serviceId: "SERVICE_ID", variant: "dialog" });
</script>

Events

EventWhenData
readyThe booking flow is shown
stepChangeThe client moves to another stepstep, index, total
slotSelectedThe client picks a time and goes ontimeSlot, appointments with locationId, serviceId and memberId
completedThe client bookedid, ids, groupId
canceledThe client closed the popup
window.$softalon.booking.on("completed", function (data) {
    // For example, send a conversion to your analytics
});

Loading the script with async

The code from Embed loads the script with async, so your page doesn't wait for it. Your own code may then run before the script is ready. Put it in the queue, which runs it once the script has loaded:

<script src="https://hairhaven.onsoftalon.com/embeds/booking.js" async></script>
<script>
    (window.softalonBookingQueue = window.softalonBookingQueue || []).push(function (booking) {
        booking.on("completed", function (data) {});
    });
</script>

Live chat

The script adds window.$softalon.chat:

<script src="https://hairhaven.onsoftalon.com/embeds/chat.js"></script>

Options

Set them as data- attributes on the script tag, or with init.

OptionValue
typefloating (default), trigger (your own buttons only) or inline (no floating chat)
positionright (default) or left
launcherbubble (round, default) or pill (with text)
textThe text of the pill button
sizesm, md (default) or lg
offsetX, offsetYDistance from the side and the bottom, in pixels (default 20)
teaserA short message next to the button
teaserDelaySeconds before the message shows (default 5)
autoOpenSeconds before the chat opens by itself, once per visit, not on phones
language, theme, accentColorLike for booking

An inline chat is an element with data-softalon-chat-inline, with data-height (default 600px) and its own data-language, data-theme and data-accent-color.

Functions

FunctionWhat it does
init(options)Changes the options and builds the floating chat again
inline(target, options)Puts an inline chat inside an element or CSS selector
open() and close()Opens or closes the chat
isOpen()Tells you whether the chat is open
hide() and show()Hides or shows the floating chat
onSessionStarted(callback)Runs your code when a visitor starts a conversation
onMessageReceived(callback)Runs your code when a message arrives in the chat
removeAllListeners()Removes your callbacks

The chat script has no queue. If you load it with async, call these functions after it has loaded, for example from the script's load event. Buttons with data-softalon-chat-trigger work either way.

Common questions

Yes. onCompleted(callback), onCanceled(callback) and removeAllListeners() still work on $softalon.booking, and so does the class softalon-booking-trigger.

Opens in