Example of using Create Folder action from Google Drive package

Build a bot that creates a folder in Google Drive.

Prerequisites

Suppose that ACME Inc stores all its monthly reports on Google Drive. To streamline the process, the company decides to develop a bot that creates a new folder at the beginning of each month and then uploads the reports to the folder.

In this example, the bot performs the following tasks:
  • Uses the Datetimepackage to retrieve the current date.
  • Uses the Create Folder action from theGoogle Drivepackage to create a folder with the current date as its name.
  • Displays the ID of the new folder.

Procedure

  1. Create a new bot.
    1. On the left panel, click Automation.
    2. Click Create new > Task Bot .
    3. In the Create Task Bot window, enter a name for the bot.
    4. Accept the default folder location: \Bots\
    5. To change the default bot storage location, click Choose and follow the prompts.
    6. Click Create and edit.
  2. The bot creates a folder at the start of every month with the format the <current date>-report as its name. To get the current date, use the Datetime > To string actionand theSystem: Date variable.
    1. From the Actions panel, find and add Datetime > To string action to the Bot editor.
    2. In Source date and time variable, click Variable, and enter $System:Date$. You can use the System: Date variable to get the current date.
    3. In Select date time format, click Custom format, and enter dd-MM-yyyy.
    4. In Assign the output to a variable, click (x) and create a string variable named currentDate.
    5. Save the changes.
  3. Connect to Google Drive.
    1. From the Actions panel, find and add Google Drive > Connect action to the Bot editor.
    2. In Username, select Insecure string, and enter the email ID associated with OAuth connection you have set up.
    3. In OAuth2 Authentication Mode, select Control Room managed. For more information, see Use Control Room managed OAuth2 authentication in Google packages.
    4. Click Pick and select the connection you have configured in Control Room.
    5. Save the changes.
  4. Create a folder.
    1. From the Actions panel, find and add Google Drive > Create Folder action.
    2. In Username, enter the email ID in Insecure string.
    3. In Parent folder name, enter the path to the parent folder where the new folder must be created. For example, aa-docs/monthly-reports.
    4. In Folder name, enter $currentDate$-report.
    5. In Returns the ID of created folder, click (x) and create a string variable named FolderID.
    6. Save changes.
  5. Display the folder ID.
    1. From the Actions panel, find and add Message Box > Message Box action within the Catch block.
    2. In Enter the message to display, enter $FolderID$.
    3. Save the changes.
    You can improve this example by using the folder ID to do additional processing. For example, you can use the Upload files action to upload files to the new folder. However, this use case is not covered in this example.
  6. Run the bot.
    If you are using device pools, you can schedule the bot to run at the start of every month.