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.5 KB
Raw Blame
import { closeOutputSchemas } from '../common/output-schemas';
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { closeAuth } from '../auth';
import { closeCreatedTriggerHooks } from './helpers';

export const newOpportunityAdded = createTrigger({
	auth: closeAuth,
	name: 'new_opportunity_added',
	displayName: 'New Opportunity Added',
	description: 'Triggers when a new opportunity is created.',
	aiMetadata: { description: 'Fires when a new opportunity (sales deal) is created in Close CRM, via a registered webhook on the opportunity-created event. Emits the full opportunity record, including its lead ID, value, and status. Use to react whenever a deal is opened. Close retries failed deliveries for up to 72 hours; repeated deliveries of the same event are ignored.' },
	classification: 'READ',
	type: TriggerStrategy.WEBHOOK,
	props: {},
	outputSchema: closeOutputSchemas.raw.opportunity,
	...closeCreatedTriggerHooks({ storeKey: 'new-opportunity-trigger', objectType: 'opportunity' }),
	sampleData: {
		annualized_expected_value: 500,
		annualized_value: 1000,
		attachments: [],
		confidence: 50,
		contact_id: null,
		contact_name: null,
		created_by: 'user_QO3f0LQE6fMbrokdE2awZLgT7pRv57S1C8Zv5Uo30TN',
		created_by_name: 'john doe',
		'custom.cf_cJd1lRfCdIWTgJGLQ84lQZXiGw7ufhdXA2F907z9Mk8': 1,
		'custom.cf_gOgoyjtw8iShE434uBERAEcR6wFoacUtlVPWcPA2EXS': 'Basic',
		'custom.cf_lHRMHDYJVogylPbe6v0DCGcU7kMqz2RJUYnAhntKOOn': 10,
		'custom.cf_usm3RdC8hm7Pb6pYo9M8lKCN1h06Edij9OdzHphwAkM': [
			'Premium support',
			'Professional services',
			'Subscription',
		],
		date_created: '2025-05-30T15:53:52.829000+00:00',
		date_lost: null,
		date_updated: '2025-05-30T15:53:52.829000+00:00',
		date_won: null,
		expected_value: 500,
		id: 'oppo_NkuyMMFjRDaY5mYQ7bywfpOmiHWPQ0h02bxJoZGwTOS',
		integration_links: [],
		lead_id: 'lead_Tn9KvxpJ2InYrwOb81TIoOuAoEchLPFJS72i0xMK2vj',
		lead_name: 'TEST LEAD',
		note: 'Test',
		organization_id: 'orga_qwPaunJJ8R6NPPVQj6Q0KicVJQtyWM45dMnH9HsWZBl',
		pipeline_id: 'pipe_2kHJXqFpYKmONEWPQijcit',
		pipeline_name: 'Sales',
		status_display_name: 'Demo Completed',
		status_id: 'stat_uqaIpeqabvBXW32bpLZkcD7mhTRvCXqEF0oGQDvOKMG',
		status_label: 'Demo Completed',
		status_type: 'active',
		updated_by: 'user_QO3f0LQE6fMbrokdE2awZLgT7pRv57S1C8Zv5Uo30TN',
		updated_by_name: 'john doe',
		user_id: 'user_QO3f0LQE6fMbrokdE2awZLgT7pRv57S1C8Zv5Uo30TN',
		user_name: 'john doe',
		value: 1000,
		value_currency: 'USD',
		value_formatted: '$10',
		value_period: 'one_time',
	},
});