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

2.0 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';

import { scrapegraphaiAuth } from '../../auth';
import { scrapegraphaiAiProps } from '../../common/ai-props';
import { scrapegraphaiApi } from '../../common/api';
import { scrapegraphaiUtils } from '../../common/utils';
import { scrapegrapghaiMonitorOutputSchema } from '../../output-schemas';

export const updateMonitorAction = createAction({
	auth: scrapegraphaiAuth,
	name: 'scrapegrapghai_update_monitor',
	outputSchema: scrapegrapghaiMonitorOutputSchema,
	displayName: 'Update Monitor',
	description: "Updates a monitor's schedule, name, formats, webhook or fetch options.",
	audience: 'ai',
	classification: 'WRITE',
	aiMetadata: {
		description:
			'Changes only the fields you set on a monitor: interval, name, formats, webhook URL or fetch options. The watched URL cannot be changed; create a new monitor for a different page.',
		idempotent: true,
	},
	props: {
		monitorId: scrapegraphaiAiProps.monitorId({ required: true }),
		interval: scrapegraphaiAiProps.interval({ required: false }),
		name: scrapegraphaiAiProps.monitorName({ required: false }),
		formats: scrapegraphaiAiProps.formats({ required: false }),
		mode: scrapegraphaiAiProps.formatMode({ required: false }),
		jsonPrompt: scrapegraphaiAiProps.jsonPrompt({ required: false }),
		jsonSchema: scrapegraphaiAiProps.jsonSchema({ required: false }),
		webhookUrl: scrapegraphaiAiProps.webhookUrl({ required: false }),
		fetchConfig: scrapegraphaiAiProps.fetchConfig({ required: false }),
	},
	async run({ auth, propsValue }) {
		return await scrapegraphaiApi.updateMonitor({
			auth,
			monitorId: propsValue.monitorId,
			interval: propsValue.interval,
			name: propsValue.name,
			formats: scrapegraphaiUtils.buildFormats({
				types: propsValue.formats,
				mode: propsValue.mode,
				jsonPrompt: propsValue.jsonPrompt,
				jsonSchema: propsValue.jsonSchema,
			}),
			webhookUrl: propsValue.webhookUrl,
			fetchConfig: propsValue.fetchConfig,
		});
	},
});