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.9 KB
Raw Blame
import {
  createTrigger,
  Property,
  TriggerStrategy,
} from '@activepieces/pieces-framework';
import { veroAuth } from '../common/auth';
export const emailOpened = createTrigger({
  auth: veroAuth,
  name: 'emailOpened',
  displayName: 'Email Opened',
  description: 'Triggered when an email is opened',
  aiMetadata: {
    description:
      'Fires when a recipient opens an email sent through Vero, representing an open/read engagement event for a specific user and campaign.',
  },
  props: {
    instruction: Property.MarkDown({
      value: `## Vero Webhook Setup
                To enable the webhooks, go to **Settings** > **Integrations** > **Webhooks** and enter the URL at which you wish to receive the webhooks.
                
                \`\`\`text
                {{webhookUrl}}
                \`\`\`
                `,
    }),
  },
  sampleData: {
    opened_at: 1435016238,
    user_agent:
      'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
    type: 'opened',
    user: {
      id: 123,
      email: '[email protected]',
    },
    campaign: {
      id: 987,
      type: 'transactional',
      name: 'Order confirmation',
      group: 'Order confirmation - Email 6',
      channel: 'email',
      subject: 'Your order is being processed!',
      'trigger-event': 'purchased item',
      permalink:
        'http://app.getvero.com/view/1/341d64944577ac1f70f560e37db54a25',
      sent_to: '[email protected]',
      variation: 'Variation A',
      locale: 'en-US',
    },
    message_id: '[email protected]',
  },
  type: TriggerStrategy.WEBHOOK,
  async onEnable(context) {
    // implement webhook creation logic
  },
  async onDisable(context) {
    // implement webhook deletion logic
  },
  async run(context) {
    const body = context.payload.body as any;
    if (body.type === 'opened') {
      return [body];
    }
    return [];
  },
});