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 { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { WebhookHandshakeStrategy } from '@activepieces/pieces-framework';

import { cannyAuth } from '../auth';

export type CannyEventType =
  | 'post.created'
  | 'post.status_changed'
  | 'comment.created'
  | 'vote.created';

export function createCannyTrigger({
  name,
  displayName,
  description,
  aiMetadata,
  eventType,
  sampleData,
}: {
  name: string;
  displayName: string;
  description: string;
  aiMetadata: { description: string };
  eventType: CannyEventType;
  sampleData: unknown;
}) {
  return createTrigger({
    auth: cannyAuth,
    name,
    classification: 'READ',
    displayName,
    description,
    aiMetadata,
    props: {},
    sampleData,
    type: TriggerStrategy.WEBHOOK,
    handshakeConfiguration: { strategy: WebhookHandshakeStrategy.NONE },
    async onEnable(_context) {
      // Canny webhooks must be configured manually in the Canny dashboard.
      // Point the webhook URL to this trigger's webhook URL.
    },
    async onDisable(_context) {
      // Nothing to clean up — webhooks are managed manually in Canny.
    },
    async run(context) {
      const payload = context.payload.body as { type?: string };
      if (payload?.type !== eventType) return [];
      return [payload];
    },
  });
}