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 { propsValidation } from '@activepieces/pieces-common';
import { googleChatApiAuth, googleChatCommon } from '../common';
import { directMessagesDropdown, spacesDropdown } from '../common/props';
import { googleChatAPIService } from '../common/requests';

export const getDirectMessageDetails = createAction({
  auth: googleChatApiAuth,
  name: 'getDirectMessageDetails',
  classification: 'READ',
  displayName: 'Get Direct Message Details',
  description: 'Retrieve details of a specific direct message by ID.',
  audience: 'both',
  aiMetadata: {
    description: 'Fetches the details of a direct-message space in Google Chat by its space/DM ID. Use to look up a one-on-one conversation. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    directMessageId: directMessagesDropdown({ refreshers: ['auth'], required: true }),
  },
  async run({ auth, propsValue }) {
    await propsValidation.validateZod(propsValue, googleChatCommon.getDirectMessageDetailsSchema);

    const { directMessageId } = propsValue;

    const response = await googleChatAPIService.getSpace({
      accessToken: auth.access_token,
      spaceId: directMessageId as string,
    });

    return response;
  },
});