Understanding how Zoho Circuit processes input and output as the data flows through the circuit helps to design and implement effective workflows. A circuit execution receives input as a JSON, then passes that input to the first state. Each state receives JSON as input and passes output mostly in the JSON format. Input and output data can be filtered and manipulated to create finer circuits.
The following fields filter and control the data flow from one state to another:
- Input Path
- Output Path
- Result Path
- Parameters
Input Path selects parts of the input JSON to pass to the state. After the input is processed by the state, Result Path selects what combination of the state result and the actual state input has to be passed to the output. Output Path further filters the data from the Result Path to pass it as state output.
Paths
In Zoho Circuit, Paths are strings beginning with $ that identify the components within JSON text. Specific parts of a JSON can be accessed by denoting their attributes in Input Path, Result Path, and Output Path.
Input Path & Parameters
Both Input Path and Parameters provide a way to control the actual input passed to the state. Input Path filters the JSON input received by using Path notation. Parameters enable you to insert a collection of key-value pairs to the input. The values of Parameters can either be static or parts of the input JSON selected as a Path.
For example, let the following JSON be the state input:
- {
- "Entry1": {
- "Name" : "John",
- "Id" :"97",
- "DOB" :"29Jan86"
- },
- "Entry2": {
- "Name" : "Tia",
- "Id" :"103",
- "DOB" :"02Dec93"
- },
- }
You can apply the Input Path as $.Entry2 within the state definition.
Then the input JSON passed to the state after applying Input Path will be:
- "Entry2": {
- "Name" : "Tia",
- "Id" :"103",
- "DOB" :"02Dec93"
- }
Result Path
Result Path enables you to manipulate the output of a state. Using Result Path, you can set the state output as a copy of the state input, the state result, or a combination of both.
The following state types can generate an output and include 'Result Path' in their definition:
- Pass
- Parallel
- Batch
- Function
- Webhook
- Circuit
By default, if Result Path is not defined, the state input will be completely replaced by the state result, and the result will be passed to the output. You can set the output as a combination of the state input and state result by defining the Result Path.
For example, suppose the input to your state includes the following:
- {
- "TicketName" : "AddNameFailure",
- "TicketId" : "12",
- "Priority" : 2
- }
Let the state result received be the following:
- "Resolve within 24 hours"
To keep the state input intact and to append the state result to it, set 'ResultPath' to $.TimeLimit:
- "resultPath" : "$.TimeLimit"
This includes the state result with the actual input:
- {
- "TicketName" : "AddNameFailure",
- "TicketId" : "12",
- "Priority" : 2,
- "TimeLimit" : "Resolve within 24 hours"
- }
Output Path
Output Path enables you to select a portion of the state output and remove the unwanted information from output JSON. If Output Path is not specified, then the entire JSON node (determined by the state input, state result and Result Path) will be sent as the state output.
For example, let the JSON below be the state output received from Result Path:
- {
- "Info": {
- "Name" : "John",
- "Id" :"97",
- "DOB" :"29Jan86"
- },
- "AddedInfo": {
- "DOJ" : "06June2020",
- "Place" :"J03A",
- },
- }
You can apply the Output Path as $.Info within the state definition:
Then the output JSON of the state will be:
- "Info": {
- "Name" : "John",
- "Id" :"97",
- "DOB" :"29Jan86"
- }