Function is a program script that performs a set of operations whenever invoked within an application. Set up functions in Zoho Circuit to actualize your business routines. Circuit's functions are serverless, where the cloud provider dynamically allocates the machine resources. Zoho Circuit enables you to write your code in Python, Node.js, Java, Go, or Zoho Deluge and run it seamlessly without caring about server management.
Set up functions in three steps:
- Create a function
- Integrate function to a circuit
- Test function integration
Create a Function
To create a function:
- Log in to the Zoho Circuit console.
- Select Functions from the top menu, then click +New Function on the left. Alternatively, you can also select +Create New in the top-right corner of the homepage, then select Function.
- Specify a function Name. This name serves as an identifier that can be used to call the function. Enter a meaningful name without any spaces.
- In the dropdown beside Name, select the programming language you will use to write the function. 'Python' is selected by default. Zoho Circuit supports
- Python
- Java
- Node.js
- Go
- Zoho Deluge.
- Add a Description for the function. Click Create.
- Write your function script in the cloud IDE or editor displayed for the selected language. To learn more about writing functions, click here.
A sample function for sending mass emails is displayed below.
- Click Save in the top-left corner.
- Select Execute, then specify the test input for executing your code. Click Execute again.
- Click the Deploy button in the top-left corner. Functions must be deployed before integrating them to a Circuit.
Integrate a Function
To associate function with a Circuit:
- Log in to Zoho Circuits console
- Select Circuits from the top menu bar.
- Select the circuit you'd like to modify. Click the Edit icon [].
- In the displayed circuit, drag and drop the Function state from the Functional States pane on the left.
- Enter a unique name for the function state.
- Select the Previous State and Next State between which the new function state has to be added. Click Create.
- Under Configuration on the right pane, you can edit the state Name optionally.
- Type 'Function' is selected by default. Select the Function Name to be added to the circuit from the drop-down.
- The Next State selected during state creation will be displayed. If you'd like to change it, select a state from the dropdown.
- Specify the Error Handling options for the state. To learn more about Error Handling, click here.
- Under Input / Output on the right, enter the Input Path, Output Path, and Result Path. To learn more about I/O paths, click here.
- In addition to the input JSON sent through the circuit to the function, you can define additional input parameters by clicking Add Parameters that will be specific to this circuit. Enter the parameter name and parameter value. These inputs will be passed to the function during execution.
- Click Save.
Test your integration
To test your integration:
- After saving your circuit, click Test Run at the top.
- Specify the test data as Input JSON for your test run, then click Next.
- Name your test run for this execution.
- Click Run. To learn more about Executions, click here.
- Check for the data received from the function.
- Modify your function settings if failure or data mismatch is encountered.
- Repeat this test until you get the required result using your function.