Moolet Information API (Bot API)
You can use the Moolet Information API or Bot API methods in a Moobot to obtain contextual information about the associated Moolet. These methods are useful in automation and other workflows where you want to verify the Moolet context before performing an action such as sending data.
Method reference
The Moolet Information API uses the following methods.
getType
Retrieves the Moolet type.
Request arguments
The method takes no arguments.
Response
The method returns one of the following parameters.
Type | Description |
---|---|
Enumerated type | One of the following:
|
If the result is WORKFLOW_ENGINE you can use the WorkflowEngine.getMessageType
method to retrieve the Workflow Engine type.
Example
Example use of the getType
method:
var MooletType = Bot.getType(); logger.warning(' Moolet type is ...' +MooletType);
getMooletName
Retrieves the Moolet name.
Request arguments
The method takes no arguments.
Response
The method returns the following parameter.
Type | Description |
---|---|
String | Name of the associated Moolet. |
Example
Example use of the getMooletName method:
if((Bot.getType() === Bot.EMPTY_MOOLET )) { logger.warning(Bot.getMooletName() + ' is an empty moolet') };
WorkflowEngine.getMessageType
Retrieves the Workflow Engine type. Returns null for non-Workflow Engine Moolets.
Request arguments
The method takes no arguments.
Response
The method returns one of the following parameters.
Type | Description |
---|---|
String | One of the following:
|
Example
Example use of the WorkflowEngine.getMessageType method:
if((Bot.getType() === Bot.WORKFLOW_ENGINE) && (Bot.workflowEngine.getMessageType() === Bot.workflowEngine.ALERT)) { logger.warning('Moolet ' + Bot.getMooletName() + ' will handle alerts') }