Deluge is the native online scripting language of the Zoho cloud environment. The following are the pre-defined functions wherein you have to define the business logic of your action.
- Execution function
- Context Handler function
- Button Click functions
These functions will be invoked at their respective invocation points.
The following system defined input arguments are available for all the functions.
Argument
|
Deluge Data Type
|
Description
|
user
|
Map
|
Contains the details of the user who is interacting with the bot.
|
org
|
Map
|
Contains the details of the organization in Zia Skills that the interacting user belongs to.
|
sessionData
|
Map
|
Contains the details of the client that is hosting the current chat session.
|
cache
|
Map
|
A temporary storage variable which is used to pass data across functions along the action execution cycle.
|
broadcast
|
Map
|
A storage variable which is used to pass data across different actions, as the user is interacting with the bot.
|
In addition to the system defined arguments listed above, all the static params defined for the action will also be available as input arguments individually for every function.
Zia Skills will populate apt values for all the variables and will pass on as input arguments for all the functions.
Session Data
The current chat session details of the client will be stored in the bot's context and these data will be available in all functions under the 'sessionData' argument. This argument consists of the following keys.
Key Name
|
Possible Values
|
Description
|
id
|
a unique id of current session
|
A unique id (session id) is assigned to every session.
|
medium
|
|
The mode of communication through which the user interacts with the bot.
|
client_host
|
|
The nature of client application that hosts the bot.
|
client_host_type
|
- The name of the mobile operating system, if 'client_host' is 'mobile'.
- The name of the web browser, if 'client_host' is 'web'.
|
The specific environment in which the client_host runs.
|
client_identifier
|
- The URL of the client web application, if 'client_identifier' is 'web'.
- The package name / bundle identifier of the mobile application, if 'client_identifier' is 'mobile'.
|
A unique identifier of the client.
|
The following is a sample value of the 'sessionData' argument.
"sessionData" : {
"id" : "1579635239811",
"medium" : "chat",
"client_host" : "web",
"client_host_type" : "Firefox 72",
}
Broadcast
If you wish your bot to remember any information related to the currently executing action, the information can be set as a map value to 'broadcast' key. This value gets retained even after the execution of the current action and will be available for all subsequent actions until the current chat session is over. Subsequent actions can use this value, as required by their business logic.
The following is a sample value of the 'broadcast' argument.
"broadcast" : {
"user_level" : "admin",
"status" : "booked"
}
Return value
Each function has its own specification of return data. Please note that it is your responsibility to fulfill the return data contract of every function for the proper functioning of your action.
Function Validations
The code that you write to define the functions would be validated by Zia Skills for syntax and return value correctness.
Syntax validation happens whenever a function is attempted to be saved. If the syntax validation fails due to any compile time errors, the function will not be saved and an apt error message would be displayed. Compile time errors includes incorrect syntax, punctuation, missing variable initialization, etc.
In addition to the above syntax validations, the return values of the functions will also be validated for every function execution. You can use the sample chat window to test the functions and view the results of the return value validations in the Logs window.
If the function's return value violates the contract specified for the function, an apt error message with the JSON element that commits the error will be displayed in the Logs window.
Every log would have been given one of the below labels, as per their purpose.
INFO - displays the debug prints whatever given in the code.
WARNING - displays the warning texts when something detected as wrong or unusual. E.g. Usage of any deprecated syntax in the code. Warnings will be ignored during action execution.
ERROR - displays the errors that occur when executing the code. E.g. syntax mismatch, unhandled exceptions. Errors will interrupt action execution and an appropriate message will be given as a response.
Please note, not only the errors committed in that current function in display will be shown in its Logs window, but the errors which are caused by other functions in the flow of the action will also be displayed here.