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 { reoonEmailVerifyAuth } from '../..';
import { createAction, Property } from '@activepieces/pieces-framework';
import { verifyEmails } from '../common/send-util';
import { createBulkEmailVerificationActionOutputSchema } from '../output-schemas';

export const createBulkEmailVerification = createAction({
  auth: reoonEmailVerifyAuth,
  name: 'create_bulk_email_verification',
  classification: 'WRITE',
  displayName: 'Create Bulk Email Verification',
  description: 'Creates an asynchronous bulk email verification task.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Submits a named batch of email addresses to Reoon for asynchronous bulk verification and returns a task_id used to poll for results. Use this instead of single-email verify when validating many addresses at once; results are not immediate — afterward call Get Bulk Email Verification Result with the returned task_id. Each address verified consumes Reoon credits.',
    idempotent: false,
  },
  outputSchema: createBulkEmailVerificationActionOutputSchema,
  props: {
    taskName: Property.ShortText({
      displayName: 'Task Name',
      description: 'Name of the verification task',
      required: true,
    }),
    emails: Property.Array({
      displayName: 'Emails',
      description:
        'Emails to verify (You can also provide multiple emails separated by comma)',
      required: true,
    }),
  },
  async run(context) {
    const emails = context.propsValue.emails as string[];

    // Each email field could be a comma separated list of emails so we need to split them
    const emailsToVerify = emails.reduce(
      (acc: string[], email: string) => [...acc, ...email.split(',')],
      []
    );

    const res = await verifyEmails(
      emailsToVerify,
      context.propsValue.taskName,
      context.auth.secret_text
    );

    return res.body;
  },
});