You can use Google Drive events, such as adding new files to—or updating existing files in—Google Drive shared folders or shared drives, to automatically run Unstructured ETL+ workflows that rely on those folders or drives as sources. This enables a no-touch approach to having Unstructured automatically process new and updated files in Google Drive as they are added or updated.
This example shows how to automate this process by adding a custom Google Apps Script project in your Google account. This project runs a script on a regular time interval. This script automatically checks for new or updated files within the specified Google Drive shared folder or shared drive. If the script detects at least one new or updated file, it then calls the Unstructured Workflow Endpoint to automatically run the specified corresponding Unstructured ETL+ workflow in your Unstructured account.
To use this example, you will need the following:
An Unstructured account, and an Unstructured API key for your account, as follows:
Sign in to your Unstructured account:
Get your Unstructured API key:
a. In the Unstructured UI, click API Keys on the sidebar.
b. Click Generate API Key.
c. Follow the on-screen instructions to finish generating the key.
d. Click the Copy icon next to your new key to add the key to your system’s clipboard. If you lose this key, simply return and click the Copy icon again.
The Unstructured Workflow Endpoint URL for your account, as follows:
A Google Drive source connector in your Unstructured account. Learn how.
Some available destination connector in your Unstructured account.
A workflow that uses the preceding source and destination connectors. Learn how.
With the project still open, on the sidebar, click the < > (Editor) icon.
In the Files tab, click Code.gs.
Replace the contents of the Code.gs
file with the following code instead:
Click the Save project to Drive button.
With the project still open, on the Files tab, click the Add a file button, and then click Script.
Name the new file Constants
. The .gs
extension is added automatically.
Replace the contents of the Constants.gs
file with the following code instead:
Replace the following placeholders:
<folder-id>
with the ID of your Google Drive shared folder or shared drive. This is the same ID that you specified
when you created your Google Drive source connector in your Unstructured account.<unstructured-api-url>
with your Unstructured API URL value.<unstructured-api-key>
with your Unstructured API key value.Click the disk (Save project to Drive) icon.
With the project still open, on the sidebar, click the alarm clock (Triggers) icon.
Click the + Add Trigger button.
Set the following values:
For Choose which function to run, select checkForNewOrUpdatedFiles
.
For Choose which deployment should run, select Head.
For Select event source, select Time-driven.
For Select type of time based trigger, select Minutes timer.
For Select minute interval, select Every 5 minutes.
If you change Minutes timer or Every 5 minutes to a different interval, you should also go back and change the number 5
in the following
line of code in the checkForNewOrUpdatedFiles
function. Change the number 5
to the number of minutes that correspond to the alternate interval you
selected:
For Failure notification settings, select an interval such as immediately, hourly, or daily.
Click Save.
With the project still open, on the sidebar, click the three lines (Executions) icon.
As soon as the first script execution completes, you should see a corresponding message appear in the Executions list. If the Status column shows Completed, then keep going with this procedure.
If the Status column shows Failed, expand the message to get any details about the failure. Fix the failure, and then wait for the next script execution to complete.
When the Status column shows Completed then, in your Unstructured account, click Jobs on the sidebar to see if a new job is running for that worklow.
If no new job is running for that workflow, then add at least one new file to—or update at least one existing file in—the Google Drive shared folder or shared drive, within 5 minutes of the next script execution. After the next script execution, check the Jobs list again.
You can use Google Drive events, such as adding new files to—or updating existing files in—Google Drive shared folders or shared drives, to automatically run Unstructured ETL+ workflows that rely on those folders or drives as sources. This enables a no-touch approach to having Unstructured automatically process new and updated files in Google Drive as they are added or updated.
This example shows how to automate this process by adding a custom Google Apps Script project in your Google account. This project runs a script on a regular time interval. This script automatically checks for new or updated files within the specified Google Drive shared folder or shared drive. If the script detects at least one new or updated file, it then calls the Unstructured Workflow Endpoint to automatically run the specified corresponding Unstructured ETL+ workflow in your Unstructured account.
To use this example, you will need the following:
An Unstructured account, and an Unstructured API key for your account, as follows:
Sign in to your Unstructured account:
Get your Unstructured API key:
a. In the Unstructured UI, click API Keys on the sidebar.
b. Click Generate API Key.
c. Follow the on-screen instructions to finish generating the key.
d. Click the Copy icon next to your new key to add the key to your system’s clipboard. If you lose this key, simply return and click the Copy icon again.
The Unstructured Workflow Endpoint URL for your account, as follows:
A Google Drive source connector in your Unstructured account. Learn how.
Some available destination connector in your Unstructured account.
A workflow that uses the preceding source and destination connectors. Learn how.
With the project still open, on the sidebar, click the < > (Editor) icon.
In the Files tab, click Code.gs.
Replace the contents of the Code.gs
file with the following code instead:
Click the Save project to Drive button.
With the project still open, on the Files tab, click the Add a file button, and then click Script.
Name the new file Constants
. The .gs
extension is added automatically.
Replace the contents of the Constants.gs
file with the following code instead:
Replace the following placeholders:
<folder-id>
with the ID of your Google Drive shared folder or shared drive. This is the same ID that you specified
when you created your Google Drive source connector in your Unstructured account.<unstructured-api-url>
with your Unstructured API URL value.<unstructured-api-key>
with your Unstructured API key value.Click the disk (Save project to Drive) icon.
With the project still open, on the sidebar, click the alarm clock (Triggers) icon.
Click the + Add Trigger button.
Set the following values:
For Choose which function to run, select checkForNewOrUpdatedFiles
.
For Choose which deployment should run, select Head.
For Select event source, select Time-driven.
For Select type of time based trigger, select Minutes timer.
For Select minute interval, select Every 5 minutes.
If you change Minutes timer or Every 5 minutes to a different interval, you should also go back and change the number 5
in the following
line of code in the checkForNewOrUpdatedFiles
function. Change the number 5
to the number of minutes that correspond to the alternate interval you
selected:
For Failure notification settings, select an interval such as immediately, hourly, or daily.
Click Save.
With the project still open, on the sidebar, click the three lines (Executions) icon.
As soon as the first script execution completes, you should see a corresponding message appear in the Executions list. If the Status column shows Completed, then keep going with this procedure.
If the Status column shows Failed, expand the message to get any details about the failure. Fix the failure, and then wait for the next script execution to complete.
When the Status column shows Completed then, in your Unstructured account, click Jobs on the sidebar to see if a new job is running for that worklow.
If no new job is running for that workflow, then add at least one new file to—or update at least one existing file in—the Google Drive shared folder or shared drive, within 5 minutes of the next script execution. After the next script execution, check the Jobs list again.