Examples of interaction with other apps
Use cases for integrating Latenode with external applications.
Table of contents:
- Using Google Group nodes
- Uploading Files to Google Drive
- Using the Add Multiple Rows node
- Using JS for file management on FTP server
- Using a Wait node to send Telegram messages sequentially
- Processing Google disk files using the Iterator node
1. Using Google Group nodes
As an example of using Google Group nodes, let's create a scenario that results in:
- retrieving a list of documents from a specific folder in Google Drive and then entering the names of the retrieved documents into a Google Sheets List on one of two sheets depending on the document name;
- generating a response "OK" to notify of successful completion.

To enable the successful execution of the scenario, we need to add 7 nodes and two routes with conditions:

- (1) A Trigger on Run once node to initiate a single scenario run immediately after clicking the Run Once button;
- (2) A List Files node that provides information about the documents in the "Test" folder on Google Drive in the form of an array. To configure the ListFiles node correctly, you need to create a authorization, choose Google Drive, and select the desired folder:

- (3) Iterator node, containing a sequence of values from the ListFiles node's array;

- (4) SetVariables node, defining the variable Name. The value of the variable is the name of one of the documents (value of the name field) passed in the Iterator node's array;

- (5)The first Add Single Row Node, adding a row to a Google spreadsheet. To configure the Add Single Row node correctly, you need to:
create a authorization;
select the necessary parameters (Google Drive, folder, Google spreadsheet, sheet in the spreadsheet - Sheet1);
content of the added cell: the value of the variable Name from the SetVariables node.

- (6) Route between the SetVariables node and the first Add Single Row node "Sales" with a filter condition {{contains(4.Name;"Sale")}};
- (7) The second Add Single Row Node, adding a row to a Google spreadsheet. To configure the Add Single Row node correctly, you need to:
create a authorization;
Select the necessary parameters (Google Drive, folder, Google spreadsheet, sheet in the spreadsheet - Sheet2).
Content of the added cell: the value of the variable Name from the SetVariables node

- (8) Route between the SetVariables node and the second Add Single Row node "Stocks" with a filter condition {{contains(4.Name;"Stock")}};
- (9) Webhook Response node, returning the response "OK" in case of successful completion of the scenario.
The outcome of the scenario will be:
- The name of the file Report Sale on the Sheet1 of the Google spreadsheet List:

- The name of the file Report Stock on the Sheet2 of the Google spreadsheet List:

- Generating a response "OK" to notify of successful completion.

2. Uploading Files to Google Drive
As an example, let's create a scenario where the outcome is the upload of files to a specific folder on Google Drive and subsequently obtaining a list of the names and identifiers of the files in that folder.

To successfully run this scenario, you need to add four nodes:

- (1) A Trigger on Webhook node with a URL to which a POST request is sent with a Form-data body containing the file TestJson;
- (2) An Upload File node that uploads the provided file to a Google Drive folder. To configure the Upload File node correctly, you need to create a authorization, choose Google Drive, and select the desired folder:

- (3) A ListFiles node that provides information about the documents in the Google Drive folder as an array. To configure the ListFiles node correctly, create a authorization, choose Google Drive, select the target folder, and specify file parameters:

- (4) A Webhook Response node that returns a response with an array of documents in case of a successful scenario completion.

The result of running the scenario will be an array of document parameters.
Upon the initial run and in an initially empty Latenode folder:


[
{
"id": "1MT_dJdfGlzTNtmr5NACqmivPRBV_Ef60",
"name": "TestJson.json"
}
]
Upon the second run:


[
{
"id": "1S-zd6DRmHA0o4aZn0jAsEkqOof6JkisX",
"name": "TestJson.json"
},
{
"id": "1MT_dJdfGlzTNtmr5NACqmivPRBV_Ef60",
"name": "TestJson.json"
}
]
3. Using the Add Multiple Rows node
To illustrate, let's create a scenario that results in transferring the representation of Airtable to a Google Sheet. The successful execution of the scenario requires adding 8 nodes.


- (1) A Trigger on Run once node to initiate a single scenario run immediately after clicking the Run Once button;
- (2) A List Records in View node retrieves an array of rows from the selected view. To configure it correctly, establish a authorization, choose the relevant database, and view. The node outputs an array with information about each row. In addition to necessary data, row information includes the creation date and identifier;


- (3) An Iterator node contains a sequence of values from the array of the List Records in View node;

- (4) A first JavaScript node processes the received information about the view's row. During processing, the required information
data["{{3.value.fields}}"]
is transformed into an array of string values separated by commas.
export default async function run({execution_id, input, data}) { // Parse the JSON string from the data of node 3 (Iterator) let record = JSON.parse(data["{{3.value.fields}}"]); // If the record exists, we transform it into an array of values, otherwise we return an empty array let recordArray = record ? Object.values(record) : []; // Create a new array let newArray = []; // We transform each value from recordArray into a string, wrap it in double quotes, // join all the values into one string separated by commas, and add it to newArray newArray.push(recordArray.map(value => `"${value}"`).join(", ")); // Return the new array return { newArray } }
The node's output is an array in the desired format:

- (5) A SetVariables node constructs a single array from the multiple arrays output by the previous JavaScript node. The output consists of an array of arrays.

- (6) A second JavaScript node processes the array of arrays into the desired format with the following code:
export default async function run({execution_id, input, data}) { // get the Arr array from data const Arr = JSON.parse(data["{{_.Arr}}"]); // convert the entire array to a string let result = JSON.stringify(Arr); // remove escape characters result = result.replace(/\\/g, ''); // replace "" with " result = result.replace(/""/g, '"'); return { result: result } }

- An Add Multiple Rows node records the view's rows into a Google Sheet. To configure the node, set up the authorization. In the Row Values field, place the output of the previous JavaScript node;

- (8) A Webhook Response node returns the response "Ok" upon successful execution of the scenario.
The result of executing the scenario is the copying of the selected view from the Airtable database to a Google Sheet.

4. Using JS for file management on FTP server
As an example of using the JavaScript node to manage files on an FTP server, let's create a scenario in which the following steps are sequentially executed:
- Retrieve a list of files from a specific directory on the FTP server.
- Retrieve a specific file, including its content, from the FTP server.
- Upload a test file to the FTP server.
- Delete the test file from the FTP server.
Each of the presented nodes can be used independently in any other scenarios. Some script parameters (file content or file path) are specified as static values but can also be parameters from previous nodes or values of global variables.
To successfully implement the scenario, it is necessary to add 6 nodes:

- (1) Trigger on Run once node to initiate a one-time execution of the script immediately after clicking the Run Once button;
- (2) JavaScript node named List Files from FTP for retrieving a list of files with code:
import FTP from 'promise-ftp'; export default async function run({execution_id, input, data, store}) { const ftp = new FTP(); try { await ftp.connect({ host: 'You_host', // Replace with your FTP server's host user: 'You_login', // Replace with your FTP username password: 'You_password' // Replace with your FTP password }); // Change to the directory you want to list files from, if needed await ftp.cwd('/htdocs'); // Get the list of files let fileList = await ftp.list(); // Filter out hidden files and folders fileList = fileList.filter(file => !file.name.startsWith('.')); // Disconnect from the FTP server await ftp.end(); // Return the file list return { fileList }; } catch (error) { // If there's an error, disconnect and throw the error await ftp.end(); throw error; } }
- (3) JavaScript node named Get File from FTP for obtaining a specific file and its content with code:
import FTP from 'promise-ftp'; export default async function run({ execution_id, input, data, store }) { const ftp = new FTP(); try { await ftp.connect({ host: 'You_host', // Replace with your FTP server's host user: 'You_login', // Replace with your FTP username password: 'You_password' // Replace with your FTP password }); // Defining the path to the file. // The parameter can be obtained from the output parameters of the previous nodes const remoteFilePath = "/htdocs/index2.html"; const stream = await ftp.get(remoteFilePath); // Read the stream and convert it to a string let fileContent = ''; for await (const chunk of stream) { fileContent += chunk.toString(); } // Disconnect from the FTP server await ftp.end(); // Extract the filename and extension const filename = remoteFilePath.replace(/^.*[\\\/]/, ''); // Remove directory path if present const extension = filename.split('.').pop(); return { content: fileContent, extension: extension, filename: filename }; } catch (error) { // If there's an error, disconnect and throw the error await ftp.end(); throw error; // The error will be handled by the platform } }
- (4) JavaScript node named Upload file to FTP for uploading a file with code:
import FTP from 'promise-ftp'; export default async function uploadFile({ execution_id, input, data, store }) { const ftp = new FTP(); try { await ftp.connect({ host: 'You_host', // Replace with your FTP server's host user: 'You_login', // Replace with your FTP username password: 'You_password' // Replace with your FTP password }); // Example: HTML content to upload const htmlContent = "<html>...</html>"; // Replace this with your actual HTML content // Convert the HTML content to a buffer const buffer = Buffer.from(htmlContent, 'utf-8'); // Defining the path to the file. // The parameter can be obtained from the output parameters of the previous nodes const remoteFilePath = '/htdocs/index3.html'; // Upload the buffer to the FTP server await ftp.put(buffer, remoteFilePath); // Disconnect from the FTP server await ftp.end(); return { message: `File uploaded successfully as ${remoteFilePath}` }; } catch (error) { // If there's an error, disconnect and throw the error await ftp.end(); throw error; // The error will be handled by the platform } }
- (5) JavaScript node named Delete file from FTP for deleting a file with code:
import FTP from 'promise-ftp'; export default async function deleteFile({ execution_id, input, data, store }) { const ftp = new FTP(); try { await ftp.connect({ host: 'You_host', // Replace with your FTP server's host user: 'You_login', // Replace with your FTP username password: 'You_password' // Replace with your FTP password }); // Defining the path to the file. // The parameter can be obtained from the output parameters of the previous nodes const remoteFilePath = '/htdocs/index3.html'; // Delete the file from the FTP server await ftp.delete(remoteFilePath); // Disconnect from the FTP server await ftp.end(); return { message: `File ${remoteFilePath} deleted successfully` }; } catch (error) { // If there's an error, disconnect and throw the error await ftp.end(); throw error; // The error will be handled by the platform } }
- (6) Webhook response node to return the message "Ok" indicating the successful execution of the scenario.
The output parameters of any of the JavaScript nodes serve as the result of the script. These parameters can be utilized as needed in other scenarios or nodes.
5. Using a Wait node to send Telegram messages sequentially
As an example of using the Wait node, let's create a scenario that results in the sequential sending of two pre-known messages. To successfully execute the scenario, several nodes need to be added:

- (1) Trigger on Webhook node, to trigger the scenario and receive data via POST about two messages and the date of sending the first message;
{ "Date": "2023-12-26T14:15:00Z", "Message1": "Message to be sent at a specified time", "Message2": "Second message to be sent after a period of time after the first" }
- (2) Wait node, to configure the time of sending the first message. The Date and Time field can be set to the
Date
parameter passed to the Webhook node. To fill in the field with a parameter from the previous node, switch the input format to Substitution;

- (3) Send a Text Message or Reply node, to send the first message to the Telegram chat. The Text field can be set to the
Message1
parameter passed to the Webhook node;

- (4) Wait node, to configure the time of sending the second message. The second message can be sent, for example, 1 minute and 30 seconds after sending the first message;

- (5) Send a Text Message or Reply node, for sending the second message to the Telegram chat. The Text field can be set to the
Message2
parameter passed to the Webhook node;

- (6) Webhook response node, for sending a message about the successful execution of the scenario.

The result of executing the scenario includes:
- Messages in the Telegram chat sent according to the settings of the Wait nodes;

- A response generated by the Webhook response node;


6. Processing Google disk files using the Iterator node
As an example of using the Iterator node, let's create a scenario that results in an array of document names located in the Latenode Google Drive folder.

To successfully run the script, you need to add 5 nodes:

- (1) A Trigger on Run once node to initiate a single scenario run immediately after clicking the Run Once button;
- (2) A ListFiles node that provides information about the documents located in the Latenode Google Drive folder in the form of an array. To configure the ListFiles node correctly, you need to create a authorization, select Google Drive, and choose the desired folder:

- (3) An Iterator node containing a sequence of values from the ListFiles node;

- (4) A SetVariables node that collects a variable as an array of document names. When configuring the SetVariables node, it is important to correctly specify the variable collection algorithm using the "add" operator:
The operand of the expression will automatically be the specified variable;
The expression's value should be selected as the "name" value from the Iterator node.

- (5) A Webhook Response node that returns the specified variable.

The result of running the script will be an array of values:
