Skip to content

Help center

The help center is switched on for the app on PurrCRM (Help center, in the Name and features card on Settings › your app › General). It answers in the user’s language where your team translated the articles: the SDK asks in CrmConfig.languageTag’s language, the phone’s unless you set it, and crm.languages lists the languages your help center is written in.

What you draw: the help center’s first screen (collections, featured articles and a search box), a collection’s list of articles, an article, and its “Was this helpful?” question. Articles come as content blocks, never HTML: you draw each block natively, in your own type and colours.

crm.help.state is a StateFlow<HelpCenterState>: collections, featured articles, loaded, loading and message (why the last read failed); and for the search, query (as typed), results, searching, searched (the query the results answer) and searchMessage. isSearch says whether to show the results rather than the collections.

  • crm.help.load() reads the collections and the featured articles together.
  • crm.help.search(query) searches at once. Debounce typing yourself: an answer to a query since replaced is dropped, and an empty query clears the results.
HelpCenterScreen.kt
@Composable
fun HelpCenterScreen(crm: Crm, openArticle: (String) -> Unit, openCollection: (String) -> Unit) {
val help by crm.help.state.collectAsState()
var typed by remember { mutableStateOf("") }
LaunchedEffect(Unit) { crm.help.load() }
LaunchedEffect(typed) {
delay(300) // debounce
crm.help.search(typed)
}
Column {
OutlinedTextField(value = typed, onValueChange = { typed = it }, label = { Text("Search for help") })
LazyColumn {
if (help.isSearch) {
items(help.results, key = { it.id }) { a ->
ListItem(headlineContent = { Text(a.title) }, modifier = Modifier.clickable { openArticle(a.slug) })
}
} else {
items(help.collections, key = { it.id }) { c ->
ListItem(
headlineContent = { Text(c.title) },
supportingContent = { Text("${c.articles} articles") },
modifier = Modifier.clickable { openCollection(c.slug) },
)
}
}
}
}
}

A Collection has its slug, title, description and the number of articles; an ArticleSummary its slug, title, summary, collection and updatedAt.

crm.help.collectionFetcher(slug) is a Fetcher<CollectionArticles>: call load(), and observe state (value, loading, message). value has the collection and its articles.

crm.help.articleSession(slug) answers an ArticleSession for your article screen:

  • load() reads it (again); state (ArticleState) has the article, loading and message;
  • rate(helpful) answers “Was this helpful?”, once at a time and only once the article is read; helpful is the answer PurrCRM kept (null before one), rating is true while one is on its way, and rateMessage says why one failed;
  • close() when the screen goes.

An Article has its title, summary, blocks, collection, related articles, updatedAt, and the language it is in of the languages it was written in.

Articles, posts, banners, carousels and ticket descriptions are lists of ContentBlocks. Draw each by its type, and skip a type you do not know (drawnBlocks(blocks) leaves them out), so a block a later PurrCRM adds never breaks your screen:

BlockTypeFieldsDraw
ParagraphspansA paragraph
Headinglevel (1 to 3), spansA heading
Bullets, Numbers, Checklistitems (each with its spans)A list
ImageimageUrl, alt, linkA picture; alt as its content description
Buttonlabel, linkA button
Divider, Spacersize for a spacerA line, or space
EyebrowspansA small label above a heading
Calloutspans, emoji, tone or colorA tinted box
EmojiemojiA large emoji

A Span is a run of text with bold, italic, underline, strike, highlight, a color and a link. In a carousel or a post, a block may also carry size, color, align, weight, aspect, fit, shape and style; elsewhere they are empty, and your defaults apply. A color is a ColorToken word (accent, ink, muted…) to map to your theme, or a fixed #rrggbb. plainText(blocks) is the words alone, for a preview.

Follow a span’s or a button’s link with crm.openLink(link): one of PurrCRM‘s pages opens through navigate, a path of your app’s through followable and openInApp, and an https address in the browser. In an in-app message, use the message’s own calls instead (In-app messages).

For a screen that keeps its own state, the same reads answer at once, and throw the CrmFailure they end with: crm.help.collections(), crm.help.collection(slug), crm.help.featured(), crm.help.find(query), crm.help.article(slug) and crm.help.rate(slug, helpful).

A link to /help, /help/collections/<slug> or /help/<slug>, in a reply, a push or a message, reaches your navigate hook as CrmPlace.HelpCenter, Collection or Article, with the slug as its id (Initialise).