Configuring a Circuit in Code View
In Code View, you can directly code a circuit in the JSON format.
A state name is a JSON object and its properties are the key-value pairs of that object. Properties like type and next are commonly used for all states. If a state does not mention the next key, it is the last state in the circuit. If a state is not referred as next in any other states, it is the first state of the circuit.
Note that you must follow the standard JSON syntax while coding a circuit.
Defining a Circuit in Code View
States consist of attributes. Enter a state name. Define the attributes for the state as key-value pairs.
Define the common fields of the state: Name, type, and next.
name: All the states must have a unique name to identify them within the circuit. In the circuit displayed above, 'Get Lead Info' and 'Send Email' are the names of two states in the circuit.
type: The actual functionality of the state is referred by its type. The types 'pass', 'branch', 'parallel', 'wait', 'batch', 'success', 'failure', 'function', 'webhook', and 'circuit' are supported. For more details about the states, go to States in Zoho Circuit.
next: The name of the next state to run after the completion of the current state. In the above example, 'Send Email' is the next state of "Get Lead Info", while the next state of "Send Emil" is End.
Define the unique fields of the states. Refer to Flow Controls to explore the fields for each state.
Provide error handling options using the 'onError' attribute for state types 'function', 'webhook', and 'circuit'.
Specify the 'inputPath', 'outputPath', and 'resultPath' for input and output processing. In this example, for the state "Get Lead Info", the 'resultPath' is '$.result' which is the lead's information obtained through the 'Record' state under Zoho CRM. The 'outputPath' is '$.result.data[0]', which is the information under the "data" object in the result as we will pass the lead's details as input to the next state.
Similarly, for the state "Send Email", the 'resultPath' and 'outputPath' will be the function's output which is sending an email to the record owner.
Click Save in the top-left menu bar.
When there is an error in the code, a red cross mark is displayed beside the error line. Hover over it to display the details of the error.
Every circuit must have one state with the field value 'start: true' to represent the beginning state.
All states except 'success' and 'failure' must have a 'next' state. The terminal state must have the 'next' state value as 'End'.
You can define the States in any sequence. The order of execution solely depends on the 'start' and 'next' fields.
All fields and their values are case-sensitive. Once you define a value, you must provide the exact value throughout the circuit.
All the standard attribute names of the state (name keys represented in black in Code View) like type, next, duration, functionName, and collectionPath are expected in camel case.