Skip to main content

init(orgId, opts?)

Initializes Command AI and injects the scripts required to load it into the head of the document. After calling this function it will be possible to access window.Command AI and call the SDK methods, even if the scripts have not finished loading yet. However, Command AI will not be available to the end-user, until boot is called.

Do I always need init?

init is only necessary when installing via the npm Command AI package. If you install via the snippet, init is not needed.

Examples

Simplest initialization

import { init } from "commandbar";

const YOUR_ORG_ID = "yourorg1";
init(YOUR_ORG_ID);

Advanced

Enable debug logging

import { init } from "commandbar";

const YOUR_ORG_ID = "yourorg1";
init(YOUR_ORG_ID, { debug: true });

Set a specific release environment

Pin your Command AI config corresponding to a specific release environment. See Releases for more info.

import { init } from "commandbar";

const YOUR_ORG_ID = "yourorg1";
init(YOUR_ORG_ID, { environment: "qa" });

Pin a specific Release version config

Pin your Command AI config to a specific release version. Note that doing this will not allow promotion to occur without a code change.

import { init } from "commandbar";

const YOUR_ORG_ID = "yourorg1";
init(YOUR_ORG_ID, { version: "v13" });

Load a local copy of your Command AI config

See Self-hosting Command AI - Config for more details.

import { init } from "commandbar";

const YOUR_ORG_ID = "yourorg1";
init(YOUR_ORG_ID, {config: {...}})

Function parameters

orgId Required

string

orgId is the UUID corresponding to your organization, which can be found in the Dashboard in the left sidenav, click your organization name at the bottom, and copy the 8-digit Org ID.

opts

object

Additional options to use for initialization:

PropertyTypeTierDescription
debugbooleanAllEnables additional logging
environmentstringEnterpriseBy default, environment loaded is latest, which always contains the latest version of Command AI. When using Releases, you can specify two additional environments ("qa", "prod"). These can be any string literal, and you'll provide them to the Command AI team to update. See Releases for more details.
versionstringEnterpriseDenotes the specific version of Command AI to load.
configobjectEnterpriseA local json copy of your organizations config. See Self-hosting Command AI - Config for more details.