Smartpoint Cloud Connector Intercepting Commands

This topic explains how to:

Registering commands to be intercepted

To register commands a message has to be sent using the operation addInterceptCommands. It will expect a list of strings. If those strings start and end with / they will be interpreted as regular expressions. The timeout parameter is optional with a default value of 500. Increasing this value may lead to worse performance.

Copy
{
    id: GUID | string,
    type: "action",
    operation: "addInterceptCommands",
    parameters: {
      regexList: Array<string>,
      timeout: Number
    }
}

Which will return a response with the same id:

Copy
{
    id: GUID | string,
    type: "action",
    operation: "addInterceptCommands",
    success: boolean,
    result: Object | string
}

Example

Initial request:

Copy
{
    "id": "123456789",
    "type": "action",
    "operation": "addInterceptCommands",
    "parameters": {
        {
            "regexList": [ "/^A/", "HELP" ],
            "timeout": 500
        }
    }
}

Expected response:

Copy
{
  "id": "123456789",
  "type": "action",
  "operation": "addInterceptCommands",
  "result": true,
  "success": true
}

If anything goes wrong you will receive a negative success and an explanation on the result.

Copy
{
  "id": "123456789",
  "type": "action",
  "operation": "addInterceptCommands",
  "result": "Something went wrong",
  "success": false
}

A cryptic is intercepted

When a cryptic is intercepted, a message will be sent to the third party application that registered it:

Copy
{
  id: GUID | string,
  type: "event",
  operation: "addInterceptCommand",
  payload: {
    cryptic: string
  }
}

This will wait for the third party application to respond with a message or the timeout happens. This message needs to have the same id as the previous one. If the value of intercept is true, the cryptic will be successfully intercepted. If the value of intercept is false or the timeout ends then the cryptic will run as normal on Smartpoint Cloud.

Copy
{
    id: GUID | string,
    type: "callback"
    operation: "addInterceptCommand",
    result:
    {
        intercept: boolean
    }
}

Example

Initial message:

Copy
{
  "id": "123456789",
  "type": "event",
  "operation": "addInterceptCommand",
  "payload": {
    "cryptic": "ABC"
  }
}

Expected response

Copy
{
    "id": "123456789",
    "type": "callback"
    "operation": "addInterceptCommand",
    "result":
    {
        "intercept": true
    }
}

Unregistering commands

To unregister commands a message has to be sent using the operation cancelInterceptCommands. It will expect a list of cryptic commands or regular expressions.

Copy
{
    id: GUID | string,
    type: "action",
    operation: "cancelInterceptCommands",
    parameters: {
      regexList: Array<string>,
    }
}

Which will return a response with the same id:

Copy
{
    id: GUID | string,
    type: "action",
    operation: "cancelInterceptCommands",
    success: boolean,
    result: Object | string
}

Unregistering all the commands

To unregister all the commands a message has to be sent using the operation cancelAllInterceptCommands.

Copy
{
    id: GUID | string,
    type: "action",
    operation: "cancelAllInterceptCommands"
}

Which will return a response with the same id:

Copy
{
    id: GUID | string,
    type: "action",
    operation: "cancelAllInterceptCommands",
    success: boolean,
    result: Object | string
}