Chat on a published map
A map you publish from Kaleidr Studio can offer its own chat. Visitors of the page where you embed the map ask questions in a chat panel, and the answers appear as pins on the embedded map. There is no API key in the page: the published map itself authorizes the chat, and the map's owner pays for the questions. This is called Visitor AI Chat, and it works on every plan, including Free.
At the end of this page you have a published Studio map embedded in your site with a chat panel docked inside it.
Before you start
- A Kaleidr account and a map in Studio.
- AI credits on the owner's organization. Every plan includes a monthly allowance.
- A page you can add HTML to, served over HTTP or HTTPS. The page needs to be able to run a script tag; site builders that accept only an iframe can show the map but not the chat.
- If your site sends a Content Security Policy, the hosts on the Content Security Policy page allowed.
Step 1: Publish the map
In Studio, open the map's Publish & embed page and choose Go Live.
You should see: the status change from "Draft" to "Live", and an Embed code section appear below it. From then on the published map shows the map as it is currently saved, so an edit you save is public the next time the page loads, with no re-publish. To change the map privately, unpublish it first and publish it again when you are done: see Embed a map.
Step 2: Switch on Visitor AI Chat
In the map editor, choose Share, then the Embed tab. Switch on Visitor AI Chat.
You should see: a second field appear, Monthly AI Credit Limit, with the placeholder "No limit".
Optionally type a limit. It is the most AI credits this map's chat may spend in one billing period of the owner's organization.
- Leave it empty for no per-map limit. The organization's own allowance is then the only ceiling.
- The value is a whole number of credits, 1 or more. The field saves when you leave it or press Enter.
- Set it to at least a few thousand. A question is admitted only while 2,000 credits are still available under the limit, so a limit below 2,000 means no question is ever answered.
Step 3: Decide which sites may embed the map (optional)
In the same Embed tab, a menu above the Visitor AI Chat switch sets who can embed the map. It has two choices:
| Choice | Effect |
|---|---|
| Any domain | Any page can embed the map and, with Visitor AI Chat on, open its chat. |
| Specific domains | Only pages on the domains you list, one per line. A domain covers its subdomains: example.com also allows www.example.com and shop.example.com. |
The list applies to both the map and the chat. Because the chat spends your credits, restrict the domains unless you intend the chat to be usable from any site. Embed a map covers the domain list in detail.
You should see: "Saved" next to the menu after each change.
Step 4: Copy the map's id
Go back to the Publish & embed page. Under Embed code, choose Developer. With Visitor AI Chat on, the
snippet contains two <kaleidr-map> elements, and both carry the same share-id. That value is your map's id.
Use the id from this page. A share link's id shows the map in a viewer element, but the chat refuses it with
404 not_found: only the published map's id opens a chat.
Step 5: Add the two elements to your page
The snippet Studio copies places the chat element after the map, so the panel appears below the map. To put the panel on the map, wrap both elements in one positioned container and stretch the chat element over it:
<script src="https://cdn.kaleidr.com/embed/v1/kaleidr.js" async></script>
<div style="position:relative">
<kaleidr-map id="store-map" product="viewer" share-id="YOUR_MAP_ID"
style="display:block; height:480px"></kaleidr-map>
<kaleidr-map product="chat" share-id="YOUR_MAP_ID" contained
map-target="#store-map"
style="display:block; position:absolute; inset:0; z-index:1; pointer-events:none"></kaleidr-map>
</div>
| Part | Why it is there |
|---|---|
position:relative on the wrapper | The chat element is positioned against it. The wrapper takes its height from the map element. |
display:block; height:480px on the viewer | The height sizes the map. <kaleidr-map> is display:block by default; writing it out also covers Safari before 16.4, where the element stays inline and a height has no effect. |
share-id on both elements | On the viewer it selects the map. On the chat element, with no key, it selects the map that provides the chat. |
contained | Docks the panel inside the chat element instead of floating it over the browser window. |
map-target="#store-map" | A CSS selector for the map the panel drives. Use an id when the page has more than one map. |
position:absolute; inset:0 on the chat element | Stretches it over the map, so the panel docks at the map's top-left corner. |
pointer-events:none | Lets the visitor drag and zoom the map everywhere the panel is not. |
You should see: your published map, with an input bar that reads Ask Kaleidr at its top-left corner.
The complete page
Save this as index.html, replace YOUR_MAP_ID in both places, and serve the folder over HTTP.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Our locations</title>
<script src="https://cdn.kaleidr.com/embed/v1/kaleidr.js" async></script>
<style>
body { margin: 0 auto; max-width: 960px; padding: 24px; font-family: system-ui, sans-serif; }
.map-frame { position: relative; }
</style>
</head>
<body>
<h1>Our locations</h1>
<div class="map-frame">
<kaleidr-map id="store-map" product="viewer" share-id="YOUR_MAP_ID"
style="display:block; height:480px"></kaleidr-map>
<kaleidr-map product="chat" share-id="YOUR_MAP_ID" contained
map-target="#store-map"
style="display:block; position:absolute; inset:0; z-index:1; pointer-events:none"></kaleidr-map>
</div>
</body>
</html>