NodeJS Escalation API - Bot Context Data Handling

The Bot app (the client of the SDK a.k.a. "the app") requests a chat passing in a requestChat that contains the getContextDataSpec property with a value that is a function.

The SDK, seeing that the property has been set, calls the corresponding function, passing the id that should be used as the contextId claim within the JWT generated. It also passes a callback function that the app can use to deliver the result.

The app generates the context data according to the specification. An example:

This object is set as the value of the contextData claim within the JWT payload.

The app signs the payload to produce a signed JWT.

The signed JWT is set as the value of the contextData property within the contextDataSpec object that is passed to the SDK via the callback function the app was given. Note that if an error occurred, this would be indicated by using a non-null value for the first argument to the callback; in this case no error occurs, so the value is null.

Within the SDK callback, the contextData property value, together with the account ID, is wrapped in an object which is then posted to the CafeX Context Data Server at the appropriate time.