Skip to content

Embedding VOL

@vol/embed is a dependency-free script (~8 kB gzipped) that adds VOL to any page. It offers three placements, all of which talk to the API directly with your key:

Placement Call Result
Inline Vol("inline", {...}) A chat rendered inside an element of your page
Floating button Vol("floatingButton", {...}) A launcher in the corner that opens the chat in a modal
Web Component <vol-chat …> A custom element you place and style like any tag

Paste before </body>. The stub queues commands until the script loads, so you can call Vol(...) immediately:

<script>
(function (w, d, src) {
w.Vol = w.Vol || function () { (w.Vol.q = w.Vol.q || []).push(arguments); };
var s = d.createElement("script"); s.async = true; s.src = src; d.head.appendChild(s);
})(window, document, "https://vol.example.com/embed/embed.js");
Vol("init", { apiKey: "vol_live_…", case: "papers" });
</script>

baseUrl defaults to <script origin>/api; set it if your API lives elsewhere.

<div id="vol-chat" style="max-width: 720px"></div>
<script>
Vol("inline", { elementOrSelector: "#vol-chat", height: "600px", title: "Ask our research library" });
</script>
Vol("on", "vol:citation", (e) => {
console.log(e.detail.citation.nodeIndex);
e.preventDefault(); // stop the default "open in the VOL map" behaviour
});
Vol("on", "vol:answer", (e) => analytics.track("vol_answer", { citations: e.detail.citations.length }));

Full option and event reference: Embed.