Session Variables for iOS
Session variables are dynamic key-value pairs maintained throughout a conversation in Zoho guided conversations (GC). They are organization-specific and accessible across multiple flows.
Set Session Variables
Swift
let variables: [[String: Any]] = [
["name": "exampleName", "value": "exampleValue"]
]
ZohoGC.setSessionVariables(botId: "YOUR_BOT_ID", sessionVariables: variables)
Objective-C
NSArray *variables = @[
@{@"name": @"exampleName", @"value": @"exampleValue"}
];
[ZohoGC setSessionVariablesWithBotId:@"YOUR_BOT_ID" sessionVariables:variables];
Update Session Variables
Swift
let variables: [[String: Any]] = [
["name": "exampleName", "value": "newValue"]
]
ZohoGC.updateSessionVariables(botId: "YOUR_BOT_ID", sessionVariables: variables)
Objective-C
NSArray *variables = @[
@{@"name": @"exampleName", @"value": @"newValue"}
];
[ZohoGC updateSessionVariablesWithBotId:@"YOUR_BOT_ID" sessionVariables:variables];
Note
The "name" and "value" keys in the session variable must not be changed or renamed.
These keys are required by the Zoho server API to correctly identify:
- the name of the session variable to be set or updated, and
- the value to assign to that variable.
If the keys are modified, the server will not recognize the data, and the session variable operation will fail. Always use "name" and "value" exactly as shown to ensure reliable integration with the backend.