← Google Drive + Azure OpenAI integrations

Chat with Azure OpenAI API on New or Modified Files (Polling) from Google Drive API

Pipedream makes it easy to connect APIs for Azure OpenAI, Google Drive and 3,000+ other apps remarkably fast.

Trigger workflow on
New or Modified Files (Polling) from the Google Drive API
Next, do this
Chat with the Azure OpenAI API
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
8 min
Watch now ➜

Trusted by 1,000,000+ developers from startups to Fortune 500 companies

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Google Drive trigger and Azure OpenAI action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New or Modified Files (Polling) trigger
    1. Connect your Google Drive account
    2. Configure timer
    3. Select a Drive
    4. Optional- Select one or more Files
    5. Optional- Select one or more Folders
    6. Optional- Configure New Files Only
  3. Configure the Chat action
    1. Connect your Azure OpenAI account
    2. Configure User Message
    3. Optional- Configure System Instructions
    4. Optional- Configure Prior Message History
    5. Optional- Configure Temperature
    6. Optional- Configure N
    7. Optional- Configure Stream
    8. Optional- Configure Stop
    9. Optional- Configure Max Tokens
    10. Optional- Configure Presence Penalty
    11. Optional- Configure Frequency Penalty
    12. Optional- Configure User
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event when a file in the selected Drive is created, modified or trashed. [See the documentation](https://developers.google.com/drive/api/v3/reference/changes/list)
Version:0.0.1
Key:google_drive-new-or-modified-files-polling

Google Drive Overview

The Google Drive API on Pipedream allows you to automate various file management tasks, such as creating, reading, updating, and deleting files within your Google Drive. You can also share files, manage permissions, and monitor changes to files and folders. This opens up possibilities for creating workflows that seamlessly integrate with other apps and services, streamlining document handling, backup processes, and collaborative workflows.

Trigger Code

import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import googleDrive from "../../google_drive.app.mjs";
import { getListFilesOpts } from "../../common/utils.mjs";
import sampleEmit from "./test-event.mjs";
import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../common/constants.mjs";

export default {
  key: "google_drive-new-or-modified-files-polling",
  name: "New or Modified Files (Polling)",
  description: "Emit new event when a file in the selected Drive is created, modified or trashed. [See the documentation](https://developers.google.com/drive/api/v3/reference/changes/list)",
  version: "0.0.1",
  type: "source",
  dedupe: "unique",
  props: {
    googleDrive,
    db: "$.service.db",
    timer: {
      type: "$.interface.timer",
      default: {
        intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
      },
    },
    drive: {
      propDefinition: [
        googleDrive,
        "watchedDrive",
      ],
      description: "Defaults to My Drive. To select a [Shared Drive](https://support.google.com/a/users/answer/9310351) instead, select it from this list.",
      optional: false,
    },
    files: {
      type: "string[]",
      label: "Files",
      description: "The specific file(s) you want to watch for changes. Leave blank to watch all files in the Drive. Note that events will only be emitted for files directly in these folders (not in their subfolders, unless also selected here)",
      optional: true,
      default: [],
      options({ prevContext }) {
        const { nextPageToken } = prevContext;
        return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
      },
    },
    folders: {
      type: "string[]",
      label: "Folders",
      description: "The specific folder(s) to watch for changes. Leave blank to watch all folders in the Drive.",
      optional: true,
      default: [],
      options({ prevContext }) {
        const { nextPageToken } = prevContext;
        const baseOpts = {
          q: "mimeType = 'application/vnd.google-apps.folder' and trashed = false",
        };
        const isMyDrive = this.googleDrive.isMyDrive(this.drive);
        const opts = isMyDrive
          ? baseOpts
          : {
            ...baseOpts,
            corpora: "drive",
            driveId: this.getDriveId(),
            includeItemsFromAllDrives: true,
            supportsAllDrives: true,
          };
        return this.googleDrive.listFilesOptions(nextPageToken, opts);
      },
    },
    newFilesOnly: {
      type: "boolean",
      label: "New Files Only",
      description: "If enabled, only emit events for newly created files (based on `createdTime`)",
      default: false,
      optional: true,
    },
  },
  hooks: {
    async deploy() {
      // Get initial page token for change tracking
      const driveId = this.getDriveId();
      const startPageToken = await this.googleDrive.getPageToken(driveId);
      this._setPageToken(startPageToken);

      this._setLastRunTimestamp(Date.now());

      // Emit sample events from the last 30 days
      const daysAgo = new Date();
      daysAgo.setDate(daysAgo.getDate() - 30);
      const timeString = daysAgo.toISOString();

      const args = this.getListFilesOpts({
        q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
        orderBy: "modifiedTime desc",
        fields: "*",
        pageSize: 5,
      });

      const { files } = await this.googleDrive.listFilesInPage(null, args);

      for (const file of files) {
        if (this.shouldProcess(file)) {
          await this.emitFile(file);
        }
      }
    },
  },
  methods: {
    _getPageToken() {
      return this.db.get("pageToken");
    },
    _setPageToken(pageToken) {
      this.db.set("pageToken", pageToken);
    },
    _getLastRunTimestamp() {
      return this.db.get("lastRunTimestamp");
    },
    _setLastRunTimestamp(timestamp) {
      this.db.set("lastRunTimestamp", timestamp);
    },
    getDriveId(drive = this.drive) {
      return this.googleDrive.getDriveId(drive);
    },
    getListFilesOpts(args = {}) {
      return getListFilesOpts(this.drive, {
        q: "mimeType != 'application/vnd.google-apps.folder' and trashed = false",
        ...args,
      });
    },
    shouldProcess(file, lastRunTimestamp) {
      // Skip folders
      if (file.mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE) {
        return false;
      }

      // Check if "new files only" mode is enabled
      if (this.newFilesOnly) {
        const fileCreatedTime = Date.parse(file.createdTime);
        // Only process files created after the last run
        if (fileCreatedTime <= lastRunTimestamp) {
          return false;
        }
      }

      // Check if specific files are being watched
      if (this.files?.length > 0) {
        if (!this.files.includes(file.id)) {
          return false;
        }
      }

      // Check if specific folders are being watched
      if (this.folders?.length > 0) {
        const watchedFolders = new Set(this.folders);
        if (!file.parents || !file.parents.some((p) => watchedFolders.has(p))) {
          return false;
        }
      }

      return true;
    },
    generateMeta(file) {
      const {
        id: fileId,
        name: summary,
        modifiedTime: tsString,
      } = file;
      const ts = Date.parse(tsString);

      return {
        id: `${fileId}-${ts}`,
        summary,
        ts,
      };
    },
    async emitFile(file) {
      const meta = this.generateMeta(file);
      this.$emit(file, meta);
    },
  },
  async run() {
    // Store the current run timestamp at the start
    const currentRunTimestamp = Date.now();
    const lastRunTimestamp = this._getLastRunTimestamp();

    const pageToken = this._getPageToken();
    const driveId = this.getDriveId();

    const changedFilesStream = this.googleDrive.listChanges(pageToken, driveId);

    for await (const changedFilesPage of changedFilesStream) {
      console.log("Changed files page:", changedFilesPage);
      const {
        changedFiles,
        nextPageToken,
      } = changedFilesPage;

      console.log(changedFiles.length
        ? `Processing ${changedFiles.length} changed files`
        : "No changed files since last run");

      for (const file of changedFiles) {
        // Get full file metadata including parents
        const fullFile = await this.googleDrive.getFile(file.id, {
          fields: "*",
        });

        if (!this.shouldProcess(fullFile, lastRunTimestamp)) {
          console.log(`Skipping file ${fullFile.name || fullFile.id}`);
          continue;
        }

        await this.emitFile(fullFile);
      }

      // Save the next page token after successfully processing
      this._setPageToken(nextPageToken);
    }

    // Update the last run timestamp after processing all changes
    this._setLastRunTimestamp(currentRunTimestamp);
  },
  sampleEmit,
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
Google DrivegoogleDriveappThis component uses the Google Drive app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer
DrivedrivestringSelect a value from the drop down menu.
Filesfilesstring[]Select a value from the drop down menu.
Foldersfoldersstring[]Select a value from the drop down menu.
New Files OnlynewFilesOnlyboolean

If enabled, only emit events for newly created files (based on createdTime)

Trigger Authentication

Google Drive uses OAuth authentication. When you connect your Google Drive account, Pipedream will open a popup window where you can sign into Google Drive and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Google Drive API.

Pipedream requests the following authorization scopes when you connect your account:

https://www.googleapis.com/auth/drive

About Google Drive

Google Drive is a file storage and synchronization service which allows you to create and share your work online, and access your documents from anywhere.

Action

Description:Create completions for chat messages with the GPT-35-Turbo and GPT-4 models. [See the documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions)
Version:0.0.2
Key:azure_openai_service-chat

Azure OpenAI Overview

The Azure OpenAI Service API provides access to powerful AI models that can understand and generate human-like text. With Pipedream, you can harness this capability to create a variety of serverless workflows, automating tasks like content creation, code generation, and language translation. By integrating the API with other apps on Pipedream, you can streamline processes, analyze sentiment, and even automate customer support.

Action Code

import azureOpenAI from "../../azure_openai_service.app.mjs";
import common from "../common/common.mjs";

export default {
  ...common,
  key: "azure_openai_service-chat",
  name: "Chat",
  description: "Create completions for chat messages with the GPT-35-Turbo and GPT-4 models. [See the documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions)",
  version: "0.0.2",
  annotations: {
    destructiveHint: false,
    openWorldHint: true,
    readOnlyHint: false,
  },
  type: "action",
  props: {
    azureOpenAI,
    userMessage: {
      type: "string",
      label: "User Message",
      description: "The user messages to provide instructions to the assistant.",
    },
    systemInstructions: {
      label: "System Instructions",
      type: "string",
      description: "The system message helps set the behavior of the assistant. For example: \"You are a helpful assistant.\"",
      optional: true,
    },
    messages: {
      label: "Prior Message History",
      type: "string[]",
      description: "_Advanced_. Because [the models have no memory of past chat requests](https://platform.openai.com/docs/guides/chat/introduction), all relevant information must be supplied via the conversation. You can provide [an array of messages](https://platform.openai.com/docs/guides/chat/introduction) from prior conversations here. If this param is set, the action ignores the values passed to **System Instructions** and **Assistant Response**, appends the new **User Message** to the end of this array, and sends it to the API.",
      optional: true,
    },
    ...common.props,
  },
  async run({ $ }) {
    const data = this._getChatArgs();
    const response = await this.azureOpenAI.createChatCompletion({
      data,
      $,
    });

    if (response) {
      $.export("$summary", `Successfully sent chat with ID ${response.id}.`);
    }

    const { messages } = data;
    return {
      original_messages: messages,
      original_messages_with_assistant_response: messages.concat(response.choices[0]?.message),
      ...response,
    };
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
Azure OpenAIazureOpenAIappThis component uses the Azure OpenAI app.
User MessageuserMessagestring

The user messages to provide instructions to the assistant.

System InstructionssystemInstructionsstring

The system message helps set the behavior of the assistant. For example: "You are a helpful assistant."

Prior Message Historymessagesstring[]

Advanced. Because the models have no memory of past chat requests, all relevant information must be supplied via the conversation. You can provide an array of messages from prior conversations here. If this param is set, the action ignores the values passed to System Instructions and Assistant Response, appends the new User Message to the end of this array, and sends it to the API.

Temperaturetemperaturestring

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

Nninteger

How many completions to generate

Streamstreamboolean

If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

Stopstopstring

Up to 4 sequences where the API will stop generating further tokens.

Max TokensmaxTokensinteger

The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).

Presence PenaltypresencePenaltystring

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

Frequency PenaltyfrequencyPenaltystring

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

Useruserstring

A unique identifier representing your end-user, which can help Azure OpenAI to monitor and detect abuse.

Action Authentication

Azure OpenAI uses API keys for authentication. When you connect your Azure OpenAI account, Pipedream securely stores the keys so you can easily authenticate to Azure OpenAI APIs in both code and no-code steps.

About Azure OpenAI

Apply large language models and generative AI to a variety of use cases

More Ways to Connect Azure OpenAI + Google Drive

Classify Items Into Categories with Azure OpenAI API on New or Modified Comments (Instant) from Google Drive API
Google Drive + Azure OpenAI
 
Try it
Classify Items Into Categories with Azure OpenAI API on New or Modified Folders (Instant) from Google Drive API
Google Drive + Azure OpenAI
 
Try it
Classify Items Into Categories with Azure OpenAI API on New Shared Drive from Google Drive API
Google Drive + Azure OpenAI
 
Try it
Classify Items Into Categories with Azure OpenAI API on New Spreadsheet (Instant) from Google Drive API
Google Drive + Azure OpenAI
 
Try it
Classify Items Into Categories with Azure OpenAI API on New Presentation (Instant) from Google Drive API
Google Drive + Azure OpenAI
 
Try it
Changes to Files in Drive from the Google Drive API

Emit new event when a change is made to one of the specified files. See the documentation

 
Try it
Changes to Specific Files from the Google Drive API

Watches for changes to specific files, emitting an event when a change is made to one of those files. To watch for changes to shared drive files, use the Changes to Specific Files (Shared Drive) source instead.

 
Try it
Changes to Specific Files (Shared Drive) from the Google Drive API

Watches for changes to specific files in a shared drive, emitting an event when a change is made to one of those files

 
Try it
New Access Proposal from the Google Drive API

Emit new event when a new access proposal is requested in Google Drive

 
Try it
New Files (Instant) from the Google Drive API

Emit new event when a new file is added in your linked Google Drive

 
Try it
Add Comment with the Google Drive API

Add an unanchored comment to a Google Doc (general feedback, no text highlighting). See the documentation

 
Try it
Copy File with the Google Drive API

Create a copy of the specified file. See the documentation for more information

 
Try it
Create Folder with the Google Drive API

Create a new empty folder. See the documentation for more information

 
Try it
Create New File From Template with the Google Drive API

Create a new Google Docs file from a template. Optionally include placeholders in the template document that will get replaced from this action. See documentation

 
Try it
Create New File From Text with the Google Drive API

Create a new file from plain text. See the documentation for more information

 
Try it

Explore Other Apps

1
-
24
of
3,000+
apps by most popular

Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Anthropic (Claude)
Anthropic (Claude)
AI research and products that put safety at the frontier. Introducing Claude, a next-generation AI assistant for your tasks, no matter the scale.
Google Sheets
Google Sheets
Use Google Sheets to create and edit online spreadsheets. Get insights together with secure sharing in real-time and from any device.
Telegram
Telegram
Telegram, is a cloud-based, cross-platform, encrypted instant messaging (IM) service.
Google Drive
Google Drive
Google Drive is a file storage and synchronization service which allows you to create and share your work online, and access your documents from anywhere.
HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Google Calendar
Google Calendar
With Google Calendar, you can quickly schedule meetings and events and get reminders about upcoming activities, so you always know what’s next.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Pipedream Utils
Pipedream Utils
Utility functions to use within your Pipedream workflows
Shopify
Shopify
Shopify is a complete commerce platform that lets anyone start, manage, and grow a business. You can use Shopify to build an online store, manage sales, market to customers, and accept payments in digital and physical locations.
Supabase
Supabase
Supabase is an open source Firebase alternative.
MySQL
MySQL
MySQL is an open-source relational database management system.
PostgreSQL
PostgreSQL
PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
AWS
AWS
Premium
Amazon Web Services (AWS) offers reliable, scalable, and inexpensive cloud computing services.
Twilio SendGrid
Twilio SendGrid
Premium
Send marketing and transactional email through the Twilio SendGrid platform with the Email API, proprietary mail transfer agent, and infrastructure for scalable delivery.
Amazon SES
Amazon SES
Amazon SES is a cloud-based email service provider that can integrate into any application for high volume email automation
Klaviyo
Klaviyo
Premium
Klaviyo unifies your data, channels, and AI agents in one platform—text, WhatsApp, email marketing, and more—driving growth with every interaction.
Zendesk
Zendesk
Premium
Zendesk is award-winning customer service software trusted by 200K+ customers. Make customers happy via text, mobile, phone, email, live chat, social media.
ServiceNow
ServiceNow
Premium
Beta
The smarter way to workflow
Slack
Slack
Slack is the AI-powered platform for work bringing all of your conversations, apps, and customers together in one place. Around the world, Slack is helping businesses of all sizes grow and send productivity through the roof.
Microsoft Teams
Microsoft Teams
Microsoft Teams has communities, events, chats, channels, meetings, storage, tasks, and calendars in one place.