Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.3 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { gmailAuth } from '../auth';
import { getGmailMessage } from './get-mail-action';
import { gmailAiGetMessageActionOutputSchema } from '../output-schemas';

export const gmailAiGetMessageAction = createAction({
  auth: gmailAuth,
  name: 'gmail_get_message',
  classification: 'READ',
  displayName: 'Get Message',
  description: 'Get a single email message by its ID.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Fetches a single email by its Gmail message ID and returns its parsed contents, including headers, body, and decoded attachments (each attachment is returned with its downloaded content directly, so a separate Get Attachment call is normally unnecessary). Use this to read the full details of a specific known message; obtain the message ID from Search Email. Idempotent: a read-only lookup that does not modify the mailbox.',
    idempotent: true,
  },
  outputSchema: gmailAiGetMessageActionOutputSchema,
  props: {
    message_id: Property.ShortText({
      displayName: 'Message',
      description: 'Message ID from a Find Email step or a Gmail trigger.',
      required: true,
    }),
  },
  async run(context) {
    return getGmailMessage({
      auth: context.auth,
      messageId: context.propsValue.message_id,
      files: context.files,
    });
  },
});