addCallback(callbackKey, callbackFn)
Adds a callback function to Command AI. See this doc that talks about how callback actions work.
Example
window.CommandBar.addCallback(
  "sayHi",
  // Assumes an argument called "name". Args are user selected options in Spotlight
  (args, context, meta) => alert(`Hi there, ${args.name}!`)
);
Attach a custom field in CB to your callback
Useful as a no-code way for teams to attach options via the CB editor to be used in the callback
window.CommandBar.addCallback("sayHi", (args, context, meta) =>
  alert(`Welcome to ${meta?.source.metadata}`)
);
Method parameters
callbackKey Required
string
Key to reference the provided function
callbackFn Required
function
Callback function, with the following signature:
| Args | Type | Description | 
|---|---|---|
| args | object | A dictionary of argument keys and the values entered by the user | 
| context | object | A dictionary reflecting the state of context when the callback was triggered by an action being executed | 
| meta | object | A dictionary containing any custom metafields supplied via the CB Action |