Script options
Every attribute the embed script understands, where to put the tag, and what happens when it loads.
The embed is one script tag. It loads asynchronously, mounts the shelf when the page is ready, and never touches your layout.
<script
src="https://app.teamshelf.ai/embed.js"
data-team="ts_yxT2lwZi7337"
data-position="bottom-right"
data-expanded="false"
async
></script>Attributes
| Attribute | Values | Default | What it does |
|---|---|---|---|
data-team | your team key | required | Which team to load. Copy it from Setup → Embed in the portal. |
data-position | top-left, top-right, bottom-left, bottom-right, left, right | the team’s setting | Overrides the corner chosen in the portal’s Look tab for this page. A corner sets the edge the shelf hangs on and where it rests when folded; left or right changes only the edge. Leave it out to use the portal setting. Unknown values are ignored. |
data-expanded | true, false | false | Start expanded, with names and status lines. Only the exact string true expands. |
data-user-token | a JWT signed by your backend | none | Identifies a signed-in user of your app, so their conversations follow them across browsers and devices. Leave it out for anonymous visitors. See Identify signed-in users. |
If data-team is missing, the script loads but doesn’t mount anything. That’s how you load it for manual mounting in a single-page app.
Placement
Put the tag anywhere — just before </body> is the usual spot. Keep async so it never blocks rendering. If the script runs before <body> exists, it waits for DOMContentLoaded and then mounts.
The script loads from app.teamshelf.ai, and the widget talks to the same origin. If your site sends a Content-Security-Policy, allow it in script-src and connect-src:
script-src https://app.teamshelf.ai;
connect-src https://app.teamshelf.ai;
img-src https://app.teamshelf.ai data:;img-src covers images bots send in conversations and any custom bot icons, which are stored as data: URLs.
One shelf per page
The embed manages a single shelf. Mounting again — a second script tag, or a call to window.TeamShelf.mount() — replaces the existing shelf rather than adding another. Use one tag per page.
What gets added to your page
The embed appends one element, <div id="teamshelf-root">, to <body>. It’s fixed-position, takes no space and sits at a very high z-index so the shelf floats above your app. Everything visible lives in an open shadow root inside it, so:
- Your page’s CSS doesn’t change how the shelf looks.
- The shelf’s CSS never leaks into your page.
The shelf remembers a few things in the browser:
- Who the visitor is. Anonymous visitors get a random id, stored in
localStorageunderteamshelf:<team key>:visitor-id. It keeps their conversations across reloads and visits. Clearing site data or switching browsers starts a new visitor. If storage is blocked, the id lasts for one page load. - Whether it’s folded, in
sessionStorageunderteamshelf:<team key>:folded. It survives reloads in the same tab and resets in a new session. If storage is blocked, the shelf simply starts unfolded.
Troubleshooting
- Nothing appears. Check the browser console and network tab. A
403fromapp.teamshelf.aimeans your origin isn’t in the team’s allowed origins. A404withUnknown teammeans the key is wrong. - The shelf shows an amber error badge. The team couldn’t load — the badge’s text says why. Usually the team isn’t fully set up yet in the portal.
- An error for a signed-in user. The user token was rejected or has expired. Check that it’s signed with your current identity secret and expires within 24 hours, and renew it when the widget asks.
- It appears twice, or flickers. You’re mounting more than once; keep a single tag or a single
mount()call.