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,
  Property,
  TriggerStrategy,
} from '@activepieces/pieces-framework';
import { uscreenAuth } from '../common/auth';
import { uscreenProps } from '../common/props';

const sampleData = {
  event: 'video_play',
  title: 'How to Build an API',
  id: 987654,
  chapter_id: 123456,
  name: 'John Doe',
  email: '[email protected]',
};

export const beganToPlayVideo = createTrigger({
  auth: uscreenAuth,
  name: 'began_to_play_video',
  displayName: 'Began to Play Video',
  description: 'Triggers when a user plays a video for the first time.',
  aiMetadata: {
    description: 'Fires when a user begins playing a video for the first time on the Uscreen storefront (event video_play). Represents an initial video-engagement event, including the video and chapter identifiers and the viewer who started it.',
  },
  props: {
    setupInstructions: uscreenProps.webhookInstructions(),
  },
  sampleData: sampleData,
  type: TriggerStrategy.WEBHOOK,

  async onEnable(context) {
    //Empty
  },

  async onDisable(context) {
    //Empty
  },

  async run(context) {
    const payload = context.payload as unknown as typeof sampleData;

    if (payload.event !== 'video_play') {
      return [];
    }

    return [payload];
  },

  async test(context) {
    return [sampleData];
  },
});