Skip to content

Help center

Your team writes help articles in PurrCRM and groups them in collections (Set up the inbox and help center). The SDK reads them for the user signed in, in their language where your team translated them; your app draws the help center’s first screen, the search, a collection and an article.

Your screenIts state
The first screen and the searchcrm.helpCenter().state (HelpCenterState)
A collectioncrm.collection(slug).state
An article, and “Did this help?”crm.article(slug).state (ArticleState)

Mount them where navigate sends them (Initialise): /help, /help/collections/<slug> and /help/<slug>. The help center is a part your team switches on for the app; crm.has("help_center") says whether the user has it.

src/help/home.ts
import { isSearch } from "crm-sdk";
const help = crm.helpCenter();
const stop = help.state.subscribe((s) => {
if (isSearch(s)) {
drawResults(s.results, s.searching, s.searchMessage); // what the last search found
} else {
drawCollections(s.collections); // each with slug, title, description and how many articles
drawFeatured(s.featured);
}
if (s.message !== null) drawFailure(s.message);
});
await help.load();
searchInput.oninput = () => help.search(searchInput.value);
// When the screen goes:
stop();
help.close();

search(query) waits until the user stops typing (350 ms) before it asks, and an empty query clears the search. query is what was typed, searched the words the results are for, and searching is on while a search waits or is on its way. crm.helpCenter({ debounceMs: 500 }) waits longer.

const collection = crm.collection(slug); // a CrmFetch
collection.state.subscribe(({ value, loading, message }) => {
if (value !== null) drawCollection(value.collection, value.articles);
});
await collection.load();
src/help/article.ts
import { drawnBlocks } from "crm-sdk";
const view = crm.article(slug);
view.state.subscribe((s) => {
if (s.article === null) return s.loading ? drawSpinner() : drawFailure(s.message);
drawTitle(s.article.title);
drawBlocks(drawnBlocks(s.article.blocks)); // see "Drawing rich text" below
drawRelated(s.article.related);
drawHelped(s.helpful, s.rating); // what the user said, and whether an answer is on its way
});
await view.load();
yesButton.onclick = () => view.rate(true); // it helped
noButton.onclick = () => view.rate(false);

An Article has title, summary, blocks, its collection, related articles, language (the one it is in) and languages (those it has), and updatedAt. An article that is not there gives a message whose sentence is articleGone.

Articles, posts, banners, a carousel’s screens and replies carry their words as ContentBlock[]. Each block has a type:

TypeWhat it draws
paragraph, heading (with level), eyebrowWords, as spans
bullets, numbers, checklistA list of items, each with spans
imageA picture: imageUrl, alt, aspect, fit, shape
buttonA button: label, link, style
calloutA box with a tone (info, good, warn)
divider, spacer, emojiA line, a space of some size, a large emoji

A Span is text with bold, italic, underline, strike, highlight, a color token and a link. drawnBlocks(blocks) leaves out a block of a type this SDK does not know, as PurrCRM means; plainText(blocks) is their words alone, a line each, for a preview or a screen reader’s summary. Follow a link with crm.openLink(link), and ask crm.linkTargetOf(link) first to draw one that goes nowhere as plain words (Links).

The help center is read for a signed-in user. For readers who are not signed in, PurrCRM hosts a public help center of its own.