Overview
This guide explains how to run your Scade flow for each row in column A of a Google Sheet, where the data (e.g., URLs) is stored. While this involves some coding, you can simply copy and paste the necessary scripts.
💡 Understanding API requests is essential, as this method relies on sending API calls to Scade. There is currently no native integration for Google Sheets, so API request handling is required.
Step 1 - Create your server API key
Step 2 - Copy your flow HTTP request
Open your flow in Scade.
Click Publish.
Open Extended settings and navigate to API.
Copy the API request URL for your flow.
Step 3 - Create your Google Sheet
Step 4 - Open Apps Script
Step 5 - Rename your script and paste the provided code
Copy the script provided below.
function runAPIsForEachCell() {
const token = 'XXXXXXXXXXXXX'; // Your actual token
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const dataRange = sheet.getRange('A2:A'); // Assuming you want to start from row 2.
const data = dataRange.getValues();
data.forEach((row, index) => {
const videoUrl = row[0]; // The value from column A (video_url).
if (videoUrl) {
// Run the POST request
const postResponse = postScadeFlow(videoUrl, token);
const taskId = postResponse.id; // Extract task_id from POST response
// Check the status of the task periodically
const getResponse = waitForTaskCompletion(taskId, token);
// Extract the text_review from the response
const textReview = extractTextReview(getResponse);
// Store the text_review in column B
sheet.getRange(index + 2, 2).setValue(textReview);
}
});
}
function postScadeFlow(videoUrl, token) {
const url = 'https://app.scade.pro/api/v1/scade/flow/40199/execute';
const payload = {
"start_node_id": "axi1-start",
"end_node_id": "AQ6K-end",
"result_node_id": "AQ6K-end",
"node_settings": {
"axi1-start": {
"data": {
"video_url": videoUrl
}
}
}
};
const options = {
method: 'post',
contentType: 'application/json',
headers: {
'Authorization': `Basic ${token}`,
'Content-Type': 'application/json'
},
payload: JSON.stringify(payload)
};
const response = UrlFetchApp.fetch(url, options);
return JSON.parse(response.getContentText()); // Returning the POST response
}
function waitForTaskCompletion(taskId, token) {
const url = `https://api.scade.pro/api/v1/task/${taskId}`;
const options = {
method: 'get',
headers: {
'Authorization': `Basic ${token}`,
'Content-Type': 'application/json'
}
};
let isCompleted = false;
let response;
// Check task status every 5 seconds for up to 2 minutes (adjust as necessary)
for (let i = 0; i < 100; i++) { // 24 attempts, 5 seconds each = 2 minutes max
Utilities.sleep(5000); // Wait for 5 seconds before checking the status again
response = UrlFetchApp.fetch(url, options);
const taskStatus = JSON.parse(response.getContentText());
// Check if the task has been completed
if (taskStatus.status === 'completed' || taskStatus.state === 'done' || taskStatus.result) {
isCompleted = true;
break;
}
}
return JSON.parse(response.getContentText()); // Return the final GET response when completed
}
function extractTextReview(response) {
// Navigate the response to find the text_review
try {
const textReview = response.result.success.text_review;
// Clean up any unwanted characters if needed
return textReview.replace(/\\n/g, ' ').trim();
} catch (e) {
return 'No text_review found';
}
}Paste it into the Apps Script editor.
Step 6 - Paste your server token
Locate the server token in Scade.
Paste it into the script where required.
Step 7 - Save and run
Step 8 - Allow the script to interact with your spreadsheet
Google will request permission to access your spreadsheet.
Approve the request to allow the script to function properly.
If concerned about security, you can analyze the script using GPT or another tool to verify its safety before running it.
Step 9 - Monitor execution and API requests
When running heavy bulk flows, be patient—each request may take up to 300 seconds.
Check if API requests were successfully sent by opening Run History in your workflow analytics.
By following these steps, you can automate bulk API calls from Google Sheets to Scade, enabling efficient data processing workflows.