Script
Executes user-defined code. User can write custom workflow logic in Java, JavaScript, Python, R or Ruby programming languages.
Categories: Helpers, Developer Tools
Type: script/v1
Actions
JavaScript
Name: javascript
Executes custom JavaScript code.
Properties
| Name | Label | Type | Description | Required |
|---|---|---|---|---|
| input | Input | OBJECT Properties{} | Initialize parameter values used in the custom code. | false |
| script | JavaScript Code | STRING | Add your JavaScript custom logic here. | true |
Example JSON Structure
{
"label" : "JavaScript",
"name" : "javascript",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/javascript"
}Output
The output for this action is dynamic and may vary depending on the input parameters. To determine the exact structure of the output, you need to execute the action.
Python
Name: python
Executes custom Python code.
Properties
| Name | Label | Type | Description | Required |
|---|---|---|---|---|
| input | Input | OBJECT Properties{} | Initialize parameter values used in the custom code. | false |
| script | Python Code | STRING | Add your Python custom logic here. | true |
Example JSON Structure
{
"label" : "Python",
"name" : "python",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/python"
}Output
The output for this action is dynamic and may vary depending on the input parameters. To determine the exact structure of the output, you need to execute the action.
R
Name: r
Executes custom R code.
Properties
| Name | Label | Type | Description | Required |
|---|---|---|---|---|
| input | Input | OBJECT Properties{} | Initialize parameter values used in the custom code. | false |
| script | R Code | STRING | Add your R custom logic here. | true |
Example JSON Structure
{
"label" : "R",
"name" : "r",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/r"
}Output
The output for this action is dynamic and may vary depending on the input parameters. To determine the exact structure of the output, you need to execute the action.
Ruby
Name: ruby
Executes custom Ruby code.
Properties
| Name | Label | Type | Description | Required |
|---|---|---|---|---|
| input | Input | OBJECT Properties{} | Initialize parameter values used in the custom code. | false |
| script | Ruby Code | STRING | Add your Ruby custom logic here. | true |
Example JSON Structure
{
"label" : "Ruby",
"name" : "ruby",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/ruby"
}Output
The output for this action is dynamic and may vary depending on the input parameters. To determine the exact structure of the output, you need to execute the action.
Java
Name: java
Executes custom Java code.
Properties
| Name | Label | Type | Description | Required |
|---|---|---|---|---|
| input | Input | OBJECT Properties{} | Initialize parameter values used in the custom code. | false |
| script | Java Code | STRING | Add your Java custom logic here. | true |
Example JSON Structure
{
"label" : "Java",
"name" : "java",
"parameters" : {
"input" : { },
"script" : ""
},
"type" : "script/v1/java"
}Output
The output for this action is dynamic and may vary depending on the input parameters. To determine the exact structure of the output, you need to execute the action.
Additional Instructions
Calling a Component Inside a Script
To call a component inside a script, you need to use the context.component object which gives you references to components and their actions.
For example, to call logger component and its info action in javascript you can use the following code:
function perform(input, context) {
context.component.logger.info({'text': 'Hello World!!!'})
return null;
}Adding Component Connection
If you want to call an action of a component which requires a connection you can define its connection inside the Script editor:
- Click on + button.
- Click on add Script component to the workflow.
- Choose Python action.
- Click on Properties tab.
- Click on Open Code Editor.
- Click on Add Component.
- Enter name of your connection.
- Click on Select... and choose your component connection.
- Click on Add.
- Select connection you want to use in the Script for that component.
Example of usage:
function perform(input, context) {
context.component.googleMaps.getAddress({'latitude': 12.5, 'longitude': 45.8});
return null;
}Defining Multiple Connections
You can also define multiple connections of the same component and then reference a particular connection when calling the action:
- Click on Add Component.
- Add another Google Maps connection with different name.
- To define which connection will be used for what action call, add connection name as the parameter of the action.
- In this case it looks like this:
context.component.googleMaps.getAddress({'latitude': 12.5, 'longitude': 45.8}, 'googleMaps2');.
Example of usage:
function perform(input, context) {
context.component.googleMaps.getAddress({'latitude': 12.5, 'longitude': 45.8}, 'googleMaps2');
context.component.googleMaps.getAddress({'latitude': 12.5, 'longitude': 45.8}, 'googleMaps');
return null;
}How is this guide?
Last updated on
ScrapeGraphAI
ScrapeGraphAI is a web scraping python library that uses LLM and direct graph logic to create scraping pipelines for websites and local documents.
SendFox
SendFox lets you automate email campaigns, complete with custom opt-in forms and landing pages, so you're not tanking your budget to get new subscribers.