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 { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { pubrioAuth } from '../../index';
import { pubrioRequest } from '../common';
export const createMonitor = createAction({
auth: pubrioAuth,
name: 'create_monitor',
classification: 'WRITE',
displayName: 'Create Monitor',
description: 'Create a new signal monitor for jobs, news, or advertisements',
audience: 'both',
aiMetadata: {
description:
'Create a new signal monitor that watches selected companies for jobs, news, and/or advertisement signals and delivers matches to a webhook, email, or sequence. Not idempotent: each call creates a separate monitor, so calling twice yields duplicates. Use to set up ongoing monitoring; to change an existing monitor use Update Monitor.',
idempotent: false,
},
props: {
name: Property.ShortText({
displayName: 'Name',
required: true,
description: 'Monitor name',
}),
detection_mode: Property.StaticDropdown({
displayName: 'Detection Mode',
required: true,
options: {
options: [
{ label: 'Company First', value: 'company_first' },
{ label: 'Signal First', value: 'signal_first' },
],
},
}),
signal_types: Property.StaticMultiSelectDropdown({
displayName: 'Signal Types',
required: true,
options: {
options: [
{ label: 'Jobs', value: 'jobs' },
{ label: 'News', value: 'news' },
{ label: 'Advertisements', value: 'advertisements' },
],
},
}),
destination_type: Property.StaticDropdown({
displayName: 'Destination Type',
required: true,
options: {
options: [
{ label: 'Webhook', value: 'webhook' },
{ label: 'Email', value: 'email' },
{ label: 'Sequences', value: 'sequences' },
],
},
}),
webhook_url: Property.ShortText({
displayName: 'Webhook URL',
required: false,
description: 'Required when destination type is webhook',
}),
email: Property.ShortText({
displayName: 'Email',
required: false,
description: 'Required when destination type is email',
}),
sequence_identifier: Property.ShortText({
displayName: 'Sequence Identifier',
required: false,
description: 'Required when destination type is sequences',
}),
record_type: Property.ShortText({
displayName: 'Record Type',
required: false,
description: 'Required when destination type is sequences',
}),
description: Property.LongText({
displayName: 'Description',
required: false,
}),
frequency_minute: Property.Number({
displayName: 'Frequency (minutes)',
required: false,
}),
max_daily_trigger: Property.Number({
displayName: 'Max Daily Triggers',
required: false,
}),
max_records_per_trigger: Property.Number({
displayName: 'Max Records Per Trigger',
required: false,
}),
companies: Property.Array({
displayName: 'Companies',
description: 'Company names',
required: false,
}),
domains: Property.Array({
displayName: 'Domains',
required: false,
}),
linkedin_urls: Property.Array({
displayName: 'LinkedIn URLs',
required: false,
}),
company_filters: Property.LongText({
displayName: 'Company Filters',
description: 'Advanced company filters as JSON string',
required: false,
}),
signal_filters: Property.LongText({
displayName: 'Signal Filters',
description: 'Signal-specific filters as JSON array string',
required: false,
}),
people_enrichment_configs: Property.LongText({
displayName: 'People Enrichment Configs',
description: 'People enrichment configs as JSON array string',
required: false,
}),
is_company_enrichment: Property.Checkbox({
displayName: 'Company Enrichment',
required: false,
defaultValue: false,
}),
is_people_enrichment: Property.Checkbox({
displayName: 'People Enrichment',
required: false,
defaultValue: false,
}),
max_failure_trigger: Property.Number({
displayName: 'Max Failure Trigger',
description: '1-10',
required: false,
}),
max_retry_per_trigger: Property.Number({
displayName: 'Max Retry Per Trigger',
description: '0-3',
required: false,
}),
retry_delay_second: Property.Number({
displayName: 'Retry Delay (seconds)',
description: '1-5',
required: false,
}),
notification_email: Property.ShortText({
displayName: 'Notification Email',
required: false,
}),
},
async run(context) {
const body: Record<string, unknown> = {
name: context.propsValue.name,
detection_mode: context.propsValue.detection_mode,
signal_types: context.propsValue.signal_types,
destination_type: context.propsValue.destination_type,
};
const destConfig: Record<string, unknown> = {};
if (context.propsValue.webhook_url)
destConfig['webhook_url'] = context.propsValue.webhook_url;
if (context.propsValue.email)
destConfig['email'] = context.propsValue.email;
if (context.propsValue.sequence_identifier)
destConfig['sequence_identifier'] =
context.propsValue.sequence_identifier;
if (context.propsValue.record_type)
destConfig['record_type'] = context.propsValue.record_type;
if (Object.keys(destConfig).length > 0)
body['destination_config'] = destConfig;
if (context.propsValue.description)
body['description'] = context.propsValue.description;
if (context.propsValue.frequency_minute != null)
body['frequency_minute'] = context.propsValue.frequency_minute;
if (context.propsValue.max_daily_trigger != null)
body['max_daily_trigger'] = context.propsValue.max_daily_trigger;
if (context.propsValue.max_records_per_trigger != null)
body['max_records_per_trigger'] =
context.propsValue.max_records_per_trigger;
if (context.propsValue.companies)
body['companies'] = context.propsValue.companies;
if (context.propsValue.domains)
body['domains'] = context.propsValue.domains;
if (context.propsValue.linkedin_urls)
body['linkedin_urls'] = context.propsValue.linkedin_urls;
if (context.propsValue.company_filters)
body['company_filters'] = JSON.parse(context.propsValue.company_filters);
if (context.propsValue.signal_filters)
body['signal_filters'] = JSON.parse(context.propsValue.signal_filters);
if (context.propsValue.people_enrichment_configs)
body['people_enrichment_configs'] = JSON.parse(
context.propsValue.people_enrichment_configs
);
if (context.propsValue.is_company_enrichment)
body['is_company_enrichment'] = context.propsValue.is_company_enrichment;
if (context.propsValue.is_people_enrichment)
body['is_people_enrichment'] = context.propsValue.is_people_enrichment;
if (context.propsValue.max_failure_trigger != null)
body['max_failure_trigger'] = context.propsValue.max_failure_trigger;
if (context.propsValue.max_retry_per_trigger != null)
body['max_retry_per_trigger'] = context.propsValue.max_retry_per_trigger;
if (context.propsValue.retry_delay_second != null)
body['retry_delay_second'] = context.propsValue.retry_delay_second;
if (context.propsValue.notification_email)
body['notification_email'] = context.propsValue.notification_email;
return await pubrioRequest(
context.auth.secret_text,
HttpMethod.POST,
'/monitors/create',
body
);
},
});