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.5 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { makeRequest } from '../common/client';
import { webexAuth } from '../common/auth';
export const newMeeting = createTrigger({
  auth: webexAuth,
  name: 'newMeeting',
  classification: 'READ',
  displayName: 'New meeting',
  description: 'Triggers when a new meeting is created. ',
  aiMetadata: {
    description:
      'Fires when a new Webex meeting is created, delivering the meeting creation event via webhook.',
  },
  props: {},
  sampleData: {},
  type: TriggerStrategy.WEBHOOK,
  async onEnable(context) {
    const response = await makeRequest(
     context.auth.access_token,
      HttpMethod.POST,
      `/webhooks`,
      {
        event: 'created',
        resource: 'meetings',
        targetUrl: context.webhookUrl,
        name: 'New Meeting Trigger Webhook',
      }
    );

    await context.store.put<WebhookInformation>('webex_new_meeting_trigger_id', {
      id: response.id,
    });
  },
  async onDisable(context) {
    const response = await context.store?.get<WebhookInformation>(
      'webex_new_meeting_trigger_id'
    );
    if (response !== null && response !== undefined) {
      await makeRequest(
       context.auth.access_token,
        HttpMethod.DELETE,
        `/webhooks/${response.id}`
      );
    }
  },
  async run(context) {
    return [context.payload.body];
  },
});

interface WebhookInformation {
  id: string;
}