← Glean-ia-acs Β· Day 49 of 56
Level 400 β€” Builder Β· APIs30 minNIST MAP

The Web SDK

Embed Chat, Search, Modal, Sidebar, and Recommendations

You'll be able to

Read first

Day 7 Lab

  1. Survey the Web SDK surfaces: Chat, Autocomplete + Search, Modal, Sidebar, Recommendations.
  2. Pick one for your app β€” inline Search box, a Modal launcher, or a docked Sidebar.
  3. Mount the component into a container element with your backend-issued token.
  4. 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

Pick an answer β€” you'll see if it's right and why.

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?

Pass threshold 80% Β· week 7 quiz

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.”

Next Β· Week 8 Day 1
Agent Run-Modes: On Glean, via API, or as MCP