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.1 KB
Raw Blame
import MailerLite from '@mailerlite/mailerlite-nodejs';
import { Property, createAction } from '@activepieces/pieces-framework';
import { mailerLiteAuth } from '../auth';
import { findSubscriberOutputSchema } from '../output-schemas';

export const findSubscriberAction = createAction({
	auth: mailerLiteAuth,
	name: 'find_subscriber',
	classification: 'READ',
	displayName: 'Find Subscriber',
	description: 'Find a subscriber by email or ID.',
	audience: 'both',
	aiMetadata: {
		description:
			'Look up a single MailerLite subscriber by their email address or subscriber ID. Use this to resolve a contact to their record (status, fields, groups) before updating or segmenting them. Read-only and idempotent.',
		idempotent: true,
	},
	outputSchema: findSubscriberOutputSchema,
	props: {
		searchValue: Property.ShortText({
			displayName: 'Email or Subscriber ID',
			placeholder: '[email protected]',
			required: true,
		}),
	},
	async run(context) {
		const client = new MailerLite({ api_key: context.auth.secret_text });
		const response = await client.subscribers.find(context.propsValue.searchValue);
		return response.data;
	},
});