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, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../auth';
import { respaidTriggersCommon } from '../common';

interface NewCampaignTriggerPayload {
    request_id?: string;
    is_campaign_created?: boolean;
    valid_files?: {
        unique_identifier: string;
        sequence_code: string;
    }[];
    invalid_files?: {
        invalid_email: Record<string, string>;
    }[];
    file_processing_report?: string;
}

export const newCampaignCreation = createTrigger({
    name: 'new_campaign_creation',
    classification: 'READ',
    displayName: 'New Campaign Creation Result',
    description: "Triggers when the campaign is created.",
    aiMetadata: {
      description: 'Fires when Respaid finishes processing a campaign import, reporting the outcome: which imported invoice records were accepted (valid) versus rejected (invalid, e.g. bad email), and a link to the processing report. Use to react to the result of creating a collection campaign.',
    },
    auth: respaidAuth,
    props: {},
    sampleData: {
        "request_id": "1234",
        "is_campaign_created": true,
        "valid_files": [{
            "unique_identifier": "1",
            "sequence_code": 'SQ###1'
        }, {
            "unique_identifier": "2",
            "sequence_code": 'SQ###2'
        }],
        "invalid_files": [{
            "invalid_email": {
                "unique_identifier_3": "3",
                "unique_identifier_4": "4"
            }
        }],
        "file_processing_report": 'https://link_excel.com'
    },
    type: TriggerStrategy.WEBHOOK,
    onEnable: respaidTriggersCommon.onEnable('new_campaign_creation'),
    onDisable: respaidTriggersCommon.onDisable('new_campaign_creation'),
    async run(context) {
        const payload = respaidTriggersCommon.getPayload(context);
        return [payload as NewCampaignTriggerPayload];
    },
})