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.7 KB
Raw Blame
import {
  createTrigger,
  Property,
  TriggerStrategy,
} from '@activepieces/pieces-framework';
import { veroAuth } from '../common/auth';
export const unsubscribeUser = createTrigger({
  auth: veroAuth,
  name: 'unsubscribeUser',
  displayName: 'Unsubscribe User',
  description: '',
  aiMetadata: {
    description:
      'Fires when a user unsubscribes from communications in Vero, representing a withdrawal of consent for a specific user (and, when applicable, the campaign that prompted it).',
  },
  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: {
    unsubscribed_at: 1435016238,
    type: 'unsubscribed',
    user: {
      id: 123,
      email: '[email protected]',
    },
    campaign: {
      campaign_title: 'Order confirmation',
      series_title: 'Order Tracking',
      channel: 'email',
      message_id: '[email protected]',
      email_subject: 'Your order is being processed!',
      variation_name: 'Control',
      template: 'Order Template',
    },
  },
  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 === 'unsubscribed') {
      return [body];
    }
    return [];
  },
});