Certain messages need to be exchanged between the client and server (the AI Processing controller in this case) over the WebSocket connection to enable and manage the task or job subscriptions.
Messages are JSON objects, with 2 common fields:
msgType for type of the messagetimestamp in RFC3339-format of the timestamp from the sender
[Tip] Typically, the client script would send the first message to subscribe to a job or task output only after the initial handshake for the WebSocket connection is established.
| Message | Sender | Format | Notes |
| subscribe | Client | {
"msgType": "subscribe",
"timestamp":"2021-07-04T07:00:00Z",
"taskID": "<taskID>", "jobID": "<jobID>", "token": "edge API token for authentication"
}
|
- Either
taskID or jobID is required - IDs can either be internal or from AI Data
|
| ack | Controller | {
"msgType": "ack",
"ackMsgType": "subscribe",
"timestamp":"2021-07-04T07:00:01Z",
"taskID": "<taskID>",
"jobID": "<jobID>",
"status": "OK"
}
|
ackMsgType refers to which message this ack is for.status may contain an error description if the request is invalid. OK for success.
|
| taskOutput | Controller | {
"msgType": "taskOutput",
"timestamp":"2021-07-04T07:00:00Z",
"taskID": "<taskID>",
"jobID": "<jobID>",
"chunkID": "<chunkID>",
"aion": { ... },
"text": "xxx",
}
| Either aion or text must be present.
aion is the engine output standard for aiWARE.- If the output is text,
text is used.
|
| unsubscribe | Client | {
"msgType": "unsubscribe",
"timestamp":"2021-07-04T07:00:00Z",
"taskID": "<taskID>",
"jobID": "<jobID>",
"token": "edge API token for authentication"
}
| This stops listening to a specific taskID or jobID. The IDs can either be internal or AI Data |
| taskStatus | Controller | {
"msgType": "taskStatus",
"timestamp":"2021-07-04T07:00:00Z",
"taskID": "<taskID>",
"jobID": "<jobID>",
"failureCode": "xxx",
"failureReason": "xxx"
"status" : "aborted, failed, complete"
}
| This sends final status changes to the client for the task. Status options are:
If failed, the failureCode and failureReason will be set. |