The Web SDK
Embed Chat, Search, Modal, Sidebar, and Recommendations
You'll be able to
- Mount a Glean Web SDK component into a web app
- Choose the right component for a given surface (inline vs. modal vs. sidebar)
Read first
Day 7 Lab
- Survey the Web SDK surfaces: Chat, Autocomplete + Search, Modal, Sidebar, Recommendations.
- Pick one for your app β inline Search box, a Modal launcher, or a docked Sidebar.
- Mount the component into a container element with your backend-issued token.
- Confirm that whichever surface you embed, results are still scoped to the signed-in user.
Working Example: Embed the Chat Component
The Web SDK mounts a Glean surface into your page. You supply a container and an auth token your backend minted for the signed-in user, and Glean handles retrieval β still permission-scoped. Verified against web_sdk.
import { GleanWebSDK } from "@gleanwork/web-sdk";
// Token is minted server-side for the signed-in user β never hard-coded.
const token = await fetchGleanTokenForCurrentUser();
GleanWebSDK.attach({
instance: "acme",
authToken: token,
// Chat docked into a sidebar surface; swap `chat` for `search`,
// `modal`, `sidebar`, or `recommendations` to change the surface.
surface: "chat",
target: document.getElementById("glean-chat")!,
});
Whichever surface you mount β Modal for an on-demand launcher, Sidebar for a persistent panel β results stay scoped to the signed-in user. Verified against web_sdk.
Check for understanding
When would you embed the Sidebar instead of the Modal, and what stays true about permissions in both?
Check yourself
1. Which set of languages does Glean ship typed Developer Platform clients for?
2. Why does a user-scoped token return different results for two different users running the same query?
3. In a Chat API response, what do the citations tell you?
4. You need to make 10,000 support tickets searchable in Glean. Which API do you use?
5. When pushing documents through the Indexing API, why must you include permission metadata?
In 10 seconds
βThe Web SDK drops Glean into your own app β Chat, Autocomplete+Search, Modal, Sidebar, Recommendations. You mount a component; Glean handles retrieval and still enforces each user's permissions.β
Agent Run-Modes: On Glean, via API, or as MCP