Integrate with Google Drive

You can use Next Matter integration steps to directly integrate your workflow with Google Drive to, for example, upload files.

Before you begin

  • Make sure you have configured the Google Drive integration in your Next Matter portal. Go to Automations library to do it.

  • Understand how data references work. See Use data references. This will help you use the captured data in the workflow steps.

  • Get a Google Drive file ID.

    Where is the file / document ID in Google
    Open your Google file - it can be a spreadsheet or a document. Copy the value from the URL of your file. `https://docs.google.com/document/d/<143uVKzah2WhnPEHY3ATwM4UM0K-hjvZ3OB_kT93qrQU>/edit`
  • Get the Google Drive folder ID. You can find it in the folder's URL, which is https://drive.google.com/drive/u/0/folders/FOLDER_ID

🚧

Good to know: Check out our ready-made templates available when you add a step and select Templates > 3rd party templates. You can use the templates to create a set of pre-configured steps.
Need a specific template? Click the Contact us button in the top right of the page and let us know.

Upload files to process and then Drive

  1. Create a step to upload a file. To do that, in your workflow add a step that's a form.
  2. Click + Add form field and select the File upload as the form field.
  3. Create the next step to upload the file to Google Drive. Click Settings to configure the step.
  4. Enter the following details:
  • Method: POST
  • URL: https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart
  • Authorization: Google Drive
  • Body type: Form-data
  • In the Body add the two following rows:
KeyTypeValue
metadatatext{"name": "{data reference to the filename of the uploaded file}", "parents":["GDRIVE_FOLDER_ID"]}
key1file{data reference to the "First File" field from the file upload step}

πŸ“˜

Note: You can only upload one file from the File Upload step.

  • If you need the Google Drive file ID of the file to be referenced in later steps, click + Create variable and create a fileid reference of the value $id.
  • Save your changes.

Give access to the file stored in Google Drive to a user

  1. Create an Integrations > Custom integration step to upload the file.
  2. Click Settings to configure the step.
  3. Enter the following details:
  • Method: POST
  • URL: https://www.googleapis.com/drive/v2/files/FILE_ID/permissions?supportsAllDrives=true&includeTeamDriveItems=true&includeItemsFromAllDrives=true
  • Authorization: Google Drive
  • Headers: Content-Type: application/json
  • In the Body enter the following data:
{
  "type": "user",
  "role": "reader OR writer",//select a permission profile
"value":"EMAIL_OF_THE_GDRIVE_ACCOUNT_TO_HAVE_ACCESS"
}
  • If you need the Google Drive file ID of the file to be referenced in later steps, click + Create variable and create a fileid reference of the value $id.
  • Save your changes.

Copy file stored in Drive

  1. Create an Integrations > Custom integration step to copy the file.
  2. Click Settings to configure the step.
  3. Enter the following details:
  • Method: POST
  • URL: https://www.googleapis.com/drive/v3/filesFILEID_OF_THE_FILE_TO_COPY/copy?supportsAllDrives=True
  • Authorization: Google Drive
  • Headers: Content-Type: application/json
  • In the Body enter the following data:
{"name": "FILENAME_OF_THE_FILE_TO_COPY", 
 "parents": ["GDRIVE_FOLDER_ID"] } 
  • If you need the Google Drive file ID of the file to be referenced in later steps, click + Create variable and create a fileid reference of the value $id.
  • Save your changes.

Create a Google Drive folder

Before you begin

  • Get the Google Drive parent folder ID. You can find it in the folder's URL, which is https://drive.google.com/drive/u/0/folders/FOLDER_ID. The parent folder is the folder in which you're creating a sub-folder.
  1. Create an Integrations > Custom integration step.
  2. Click Settings to configure the step.
  3. Enter the following details:
  • Method: POST
  • URL: `https://www.googleapis.com/drive/v3/files
    Note that for the request to work, you need to give full access to the parent folder, such as the "Anyone with the link can edit" permission.
  • Authorization: Google Drive
  • Headers: Content-Type: application/json
  • In the Body enter the following data:
{
    "name": "FOLDER_NAME",//if the name was referenced in a previous step, use data reference. If not use real value.
    "mimeType": 'application/vnd.google-apps.folder',
     "parents": ["PARENT_FOLDER_ID"] //if the ID was referenced in a previous step, use data reference. If not use real value.
}
  • If you need the Google Drive file ID of the file to be referenced in later steps, click + Create variable and create a folderid reference of the value $id.

If you need to move a file to this newly created folder, create a follow-up integrations step with the following details:

  • Method: PATCH
  • URL: https://www.googleapis.com/drive/v3/files/FILE_ID?addParents=FOLDER_ID
  • Authorization: Google Drive
  • Headers: Content-Type: application/json
  • Body is empty

Move a file to a new folder

You can move a file from one folder to another in Google Drive.

  1. In Next Matter, create an Integrations > Custom integration step.
  2. Click Settings to configure the step.
  3. Enter the following details:
  • Method: PATCH
  • URL: https://www.googleapis.com/drive/v3/files/FILE_ID?addParents=PARENT_FOLDER_ID

πŸ“˜

The file ID and the parent folder ID can also be references to data from previous steps.

  • Authorization: Google Drive
  • Body is empty.

Replace one file with another

  1. Create a step to upload a file. To do that, in your workflow add an action step.
  2. Click + Add action and select the File upload as the action type.
  3. Create the next step to replace an old file with the uploaded one in Google Drive. Click Settings to configure the step.
  4. Enter the following details:
  • Method: PUT
  • URL: https://www.googleapis.com/upload/drive/v3/FILE_ID
  • Authorization: Google Drive
  • Body type: Form-data
  • In the Body add the two following rows:
KeyTypeValue
metadatatext{"name": "{data reference to the filename of the uploaded file}"}
key1file{data reference to the uploaded file}
  • If you need the Google Drive file ID of the file to be referenced in later steps, click + Create variable and create a fileid reference of the value $id.
  1. Save your changes.