Skip to main content

Recommendations

The Recommendations component surfaces intelligent, context-aware suggestions for the page the user is currently viewing, with a built-in Glean search box for manual searches.

portal.internal/engineering/runbooks/payments
Search for anything at Glean
Recommended for this page
C
Checkout — On-call RunbookUpdated 4 days ago
J
PAY-2114: Canary alarms during deployIn review
P
Priya Natarajan — Payments PlatformTech lead

Illustrative previewRendered with sample data — in your app, this component renders live against your organization's Glean instance.

Install the SDK

npm install @gleanwork/web-sdk

Render recommendations

  1. Create a container element with position: relative, display: block, and a defined width (800px maximum recommended — the widget adjusts to its container).

  2. Render the widget into your container:

import { renderRecommendations } from '@gleanwork/web-sdk';

renderRecommendations(document.getElementById('recommendations'), {
backend: 'https://{your}-be.glean.com/',
height: 700,
customizations: {
border: '1px solid grey',
borderRadius: 4,
horizontalMargin: 3,
verticalMargin: 3,
searchBox: {
placeholderText: 'Search for anything...',
},
},
});

Options

The most commonly used RecommendationsOptions:

OptionTypeDescription
heightnumberTotal widget height in the open state, in pixels. Defaults to 650.
customizationsRecommendationsBoxCustomizationsBorder, shadow, margins, search-box styling, and the empty-state hint.
sourceDocumentDocumentContextThe document to recommend against. Defaults to the embedding page itself.
onSearch(query) => voidInvoked when the user performs a search from the built-in box.
datasourcesFilterstring[]Restrict results to specific datasources, e.g. ['jira', 'confluence'].

All components also accept the common Optionsbackend, authToken, theme, themeVariant, locale, and more.

note

When adding a boxShadow, provide enough verticalMargin and horizontalMargin for it to be visible — margin values must be positive and apply to both sides of the component.