From Bright Pattern Documentation

Revision as of 01:25, 3 April 2026 by Laura.donovan (talk | contribs) (Updated via BpClonePage extension. Source page: draft:AgentDesktop-client-side-javascript-api-specification/setVariable)

< Previous | Next >
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

setVariable

Sets a custom scenario variable for the associated server's scenario. If the interactionId value isn't specified, the system will set a variable for the currently active interaction.

Request

Syntax

setVariable(key: string, value: string, interactionId?: string): Promise<OperationResult<null>>


Parameters

Parameters Parameter Values Data Type Optional/Required Description
key String Required Allows you to enter a scenario variable name
value String Required Allows you to enter a scenario variable value
interactionId String Optional The ID of interaction for which you want to set a variable. If no ID is provided, the variable will be set in the currently active interaction.


Example Request

setVariableButton.onclick = () => {

    const variableName = variableNameInput.value

    const variableValue = variableValueInput.value

    const itemId = activeInteractionIdInput.value

    adApi.setVariable(variableName, variableValue, itemId)
}

Return Value

null

< Previous | Next >