From Bright Pattern Documentation
getVariables
Requests values for the provided set of variables from the BPCC server's scenario. If no interactionId value is specified, the system will request variables for the active interaction.
Request
Syntax
| getVariables(keys: string[], interactionId?: string): Promise<OperationResult<Record<string, string>>> |
Parameters
| Parameters | Parameter Values | Data Type | Optional/Required | Description |
| keys | string[] | Required | A list of scenario variable names for which you want the corresponding values. | |
| interactionId | String | Optional | The ID of the interaction for which you want to get the values of certain variables. If no ID is provided, the currently active interaction will be used. |
Example Request
adApi.getVariables(["service.name", "service.version", "service.EWT"]).then(result => {
if (result.status === "success") {
const serviceName = result.data["service.name"]
const serviceVersion = result.data["service.version"]
const serviceEWT = result.data["service.EWT"]
} else {
console.error("Something went wrong:", result.error.message)
}
})
Return Value
| Object | Object Values | Data Type | Optional?
(Y/N) |
Value Description |
| Result | Variables names | Record<string, string> | Y | Object containing key-value pairs for the requested scenario variables. |