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.2 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction } from '@activepieces/pieces-framework';
import { hedyAuth } from '../../auth';
import { createClient, unwrapResource } from '../../common/client';
import { commonProps } from '../../common/props';
import { Topic } from '../../common/types';
import { assertIdPrefix } from '../../common/validation';

export const getTopic = createAction({
  auth: hedyAuth,
  name: 'get-topic',
  classification: 'READ',
  displayName: 'Get Topic',
  description: 'Retrieve details for a specific topic.',
  audience: 'both',
  aiMetadata: {
    description: 'Fetch a single Hedy topic by its ID (must be prefixed with "topic_"). Use when you already have a topic ID and need its details. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    topicId: commonProps.topicId,
  },
  async run(context) {
    const topicId = assertIdPrefix(context.propsValue.topicId as string, 'topic_', 'Topic ID');
    const client = createClient(context.auth);
    const response = await client.request<Topic>({
      method: HttpMethod.GET,
      path: `/topics/${topicId}`,
    });

    return unwrapResource(response);
  },
});