Documentation

Powered by Algolia

Client API methods

Alan exposes a set of its Client API methods that you can use to enable communication between the client app and Alan and to trigger voice activities on the client side.

The methods below are supported on all platforms:

setVisualState(visualStateData:object)

Method for setting the visual state. For details, see Visual state.

Name Type Description
visualStateData object Object that represents the visual state

Examples:

callProjectApi(method:string, data:object, callback:function)

Method for calling a project API defined in the script in the Alan Studio project. For details, see projectAPI.

Name Type Description
method string projectAPI method name that is defined in the voice script
data object Any object with custom data that must be sent to the voice script
callback function Callback that can be called from the project API method
// Voice script where your method defined like this:
projectAPI.setClientData = function(p, param, callback) {
  p.userData = param;
  callback();
};

Examples:

playText(text:string)

Method for playing voice.

Name Type Description
text string Text that must be played

Examples:

playCommand(command:object)

Method for executing a command locally in the client app. The command is handled with the onCommand handler.

Name Type Description
command object JSON object that represents a command

Examples:

activate()

Method for turning on the Alan button programmatically.

Examples:

deactivate()

Method for turning off the Alan button programmatically.

Examples:

isActive()

Method for checking the Alan button state. Returns true if the Alan button is activated by the user or programmatically or false if the Alan button is deactivated by the user or programmatically.

Examples: