com.webos.service.contextintentmgr

API Summary

CIM is a service that adds AI logic to your web app, without actually modifying its source code. This makes your web app context-aware and therefore provide a better experience to your customers.

How does it work:

  1. The CIM service interacts with an app and workflow (defined by the Workflow Designer toolkit).
  2. The workflow must specify:
    • The AI engine to be used.
    • The condition, and the action to be performed when that condition is satisfied.
    • Whether the app and workflow need to share data.
      • If yes, then the workflow must include the 'data-inject' and/or 'data-publish' nodes.
      • The app must correspondingly invoke the 'injectDataToWorkflow' and/or 'getDataFromWorkflow' methods.
  3. The workflow is packaged with the app.
  4. The packaged app is then deployed on the device.

Overview of the API

(click to expand)

NA


Open All


injectDataToWorkflow

Description

Injects data from the app to the workflow. 

Parameters

Name

Required

Type

Description

keyRequiredString

Identifies the 'data-inject' node that is defined in the workflow. 

Note: Make sure that the key is associated with the relevant 'data-inject' node.

dataRequiredString

The actual data that must be sent to the workflow. It must be a stringified object.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

resultRequiredObject: result

Contains the result.

Example


getDataFromWorkflow

Description

Publishes data from the workflow to the app.

The data can be consumed by an app which has subscribed to it.

Parameters

Name

Required

Type

Description

keyRequiredString

Identifies the 'data-publish' node that is defined in the workflow.

Note: Make sure that the key is associated with the relevant 'data-publish' node.

subscribeRequiredBoolean

Subscribe for notifications when value changes. Possible values are:

  • true - Get notifications
  • false - Notifications are not required

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

subscribedRequiredBoolean

Indicates if subscribed to get notified when there is a change in value.

  • true - Subscribed for changes
  • false - Not subscribed
resultRequiredObject: result

Contains the result.

Subscription Returns

Name

Required

Type

Description

subscribedRequiredBoolean

Indicates if subscribed to get notified when there is a change in value.

  • true - Subscribed for changes
  • false - Not subscribed
resultRequiredObject: result

Contains the result.

Example


Objects

result

Contains the results.

Name

Required

Type

Description

dataRequiredObject

Depending on the method:

  • For injectDataToWorkflow: It is the same data that is sent in the input of the method.
  • For getDataFromWorkflow: The data that is published from the flow (the msg object of the flow).
  • Example:
    {
        data: {
            payload: {
                winner: undefined,
                depth: 8,
                nextBestGameState: ['X', '', '', '', 'O', '', '', '', '']
            },
            _msgid: 'bb8697a9.d885e8'
        }
    }

API Error Codes Reference

Error Code

Error Text

Error Description

0Not a JSON data in the data-inject request.

The 'data-inject' request does not include JSON data.

0Invalid call to API

Invalid call to API

0Could not inject data

Could not inject the data.

0Associated flow is disabled, calls to APIs does not work

This error is thrown when workflow is disabled.

0Caller does not have permission for this API.

This error is thrown when the calling application does not include a 'data-inject' or 'data-publish' node with the specified key.


Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.