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.8 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';

import { googleAdsAuth } from '../auth';
import { googleAdsApi } from '../common/api';
import { googleAdsProps } from '../common/props';
import { googleAdsUtils } from '../common/utils';
import { customerMatchOutputSchema } from '../output-schemas';

export const removeCustomerMatchData = createAction({
  name: 'removeCustomerMatchData',
  classification: 'DESTRUCTIVE',
  displayName: 'Remove Customer Match Data',
  description: 'Remove members (by e-mail, phone or address) from a Customer Match audience list (Data Manager API)',
  audience: 'both',
  aiMetadata: {
    description:
      'Remove people from a CRM-based Customer Match audience list, matched by e-mail, phone or full address (e-mails, phones, first and last names are SHA-256 hashed; country code and postal code are sent unhashed). Use for opt-outs or deletion requests; to add people use Add customer match data. Processing is asynchronous; removing members that are not in the list is harmless, so retries are safe.',
    idempotent: true,
  },
  auth: googleAdsAuth,
  props: {
    customerId: googleAdsProps.customerId({ required: true }),
    userList: googleAdsProps.userList({ required: true }),
    members: googleAdsProps.members({ required: true }),
    waitForCompletion: googleAdsProps.waitForCompletion({ required: false }),
  },
  outputSchema: customerMatchOutputSchema,
  async run(context) {
    const { customerId, userList, members, waitForCompletion } = context.propsValue;
    return await googleAdsApi.uploadCustomerMatch({
      auth: context.auth,
      customerId,
      userList,
      members: (members ?? []).map(googleAdsUtils.toMemberInput),
      mode: 'remove',
      waitForCompletion: Boolean(waitForCompletion),
    });
  },
});