Upload, download, and get media as an attachment

When the user sends a message to your app, Google Chat dispatches a MESSAGE interaction event. The interaction event received by your app includes a request body, which is the JSON payload representing the interaction event, including any attachments. The data in the attachment is different depending on whether the attachment is uploaded content (a local file) or is a file stored on Drive. The Media resource represents a file uploaded to Google Chat, like images, videos, and documents. The Attachment resource represents an instance of media—a file—attached to a message. The Attachment resource includes the metadata about the attachment, such as where it's saved.

With the Google Chat API, you can asynchronously upload media and attach it to a message, as well as download media as an attachment by calling corresponding methods. The guide in this section explains how to do the following: