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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import {
createTrigger,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import { isNil } from '@activepieces/pieces-framework';
import { zagomailAuth } from '../auth';
import { zagoMailApiService, } from '../common/request';
import { StoredWebhookId, WebhookResponse } from '../common/constants';
const CACHE_KEY = 'zagomail_added_subscriber_trigger';
export const addedSubscriber = createTrigger({
auth: zagomailAuth,
name: 'addedSubscriber',
displayName: 'Subscriber Added',
description: 'Triggers when subscriber is signed up or confirmed.',
aiMetadata: {
description: 'Fires when a subscriber is activated in Zagomail (signed up and confirmed), representing a new confirmed contact joining a list. The event payload includes the subscriber UID, list UID, email, status, and custom fields.',
},
props: {},
type: TriggerStrategy.WEBHOOK,
sampleData: {
action: 'subscriber-activate',
subscriber_uid: 'dg307jyx044e1',
list_uid: 'or449cjkqqfb2',
email: '[email protected]',
status: 'confirmed',
created_at: '2025-05-11 08:26:16',
custom_fields: {
FNAME: 'gs03',
LNAME: 'dev',
},
},
async onEnable(context) {
const response = (await zagoMailApiService.createWebhook(
context.auth.secret_text,
context.webhookUrl,
'subscriber-activate'
)) as WebhookResponse;
await context.store.put<StoredWebhookId>(CACHE_KEY, {
webhookId: response.id,
});
},
async onDisable(context) {
const webhook = await context.store.get<StoredWebhookId>(CACHE_KEY);
if (!isNil(webhook) && !isNil(webhook.webhookId)) {
await zagoMailApiService.deleteWebhook(context.auth.secret_text, webhook.webhookId);
}
},
async run(context) {
return [context.payload.body];
},
});