Skip to main content

Context it receives

When an app is opened, ConsulPoint hands it an object with everything it needs to know: window.MINI_APP_PARAMS. It's the only source of context, and it's available before the app's code runs.

Common parameters​

ParameterValuesContent
languagees · enThe user's language
themelight · darkActive visual theme
tokentextTemporary session for calling the API
apiBaseUrladdressAPI base. Don't hard-code it
miniAppIdidentifierThe app's identifier

Parameters by place​

Where it's openedParameterContent
HomeapplicationIdThe app's identifier
Knowledge Hub folderfolderIdOpen folder
File previewidExtraction of the file on screen
ConversationschatIdOpen conversation
ConversationsaiResponseEnabled"true" or "false", depending on whether automatic replies are on

All values are text. A parameter that doesn't apply to the place isn't present.

How to read it​

Read it in a single module and don't access the object from components or services:

src/config.ts
export function getConfig() {
const params = window.MINI_APP_PARAMS ?? {};
return {
language: params.language ?? 'es',
theme: params.theme ?? 'light',
token: params.token ?? null,
apiBaseUrl: params.apiBaseUrl ?? null,
miniAppId: params.miniAppId ?? null,
folderId: params.folderId ?? null,
chatId: params.chatId ?? null,
};
}

When it changes​

If the user changes language, theme, folder or conversation, ConsulPoint reloads the app with the new context. You don't need to listen for changes. If the platform sends a new context without reloading, the optional mini-app-context event fires on window.

How the context arrives​

The app is served from its own domain, separate from the platform's. When it loads, it tells ConsulPoint it's ready and receives the context; meanwhile, its scripts wait, and they run in order once window.MINI_APP_PARAMS exists. That's why you should avoid in your code:

  • document.write;
  • relying on document.readyState being loading;
  • on… attributes in the HTML that call functions from your own code.

That's also why the app must not assume its in-memory state is kept: whatever matters is saved on the platform.

The four states of a screen​

Every screen must handle these situations and never be left blank in any of them:

StateWhen it happens
LoadingWhile starting up or querying data
No contextA required parameter is missing, for example the folder
ErrorA query failed
EmptyThe query responded, but there's no data

The No context state isn't an error: it's a normal situation, explained with a clear message, for example asking the user to choose a folder.

Best practices​

The token

Don't store the token in browser storage, don't write it to the console and don't include it in addresses.

Language and theme

Apply the theme on startup and provide all texts in Spanish and English.