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.8 KB
Raw Blame
import {
  createTrigger,
  TriggerStrategy,
  Property,
} from '@activepieces/pieces-framework';
import { documentproAuth } from '../common/auth';

export const newDocument = createTrigger({
  auth: documentproAuth,
  name: 'newDocument',
  displayName: 'New Document',
  description: 'Triggers when a new document is uploaded to DocumentPro',
  aiMetadata: {
    description:
      'Fires when a DocumentPro workflow finishes processing a document and emits a status-change webhook (e.g. parsing completed), delivering the document metadata and extracted result data. Requires the webhook URL to be configured in the DocumentPro workflow dashboard.',
  },
  props: {
    webhook_info: Property.MarkDown({
      value: `
**In DocumentPro Dashboard:**
   - Navigate to your desired Workflow
   - Go to the "Workflow" tab
   - Find the "Webhook Notification" option in the export section
   - Set the Webhook Endpoint URL to:
            \`\`\`text
			{{webhookUrl}}
			\`\`\`
   - Click Save

 `,
    }),
  },
  sampleData: {
    event: 'file_request_status_change',
    timestamp: '2024-07-25T14:30:29.565249',
    data: {
      request_id: 'a7813466-6f9a-4c33-8128-427e7a4df755',
      request_status: 'completed',
      response_body: {
        file_name: 'sample_document.pdf',
        template_id: '8e9beda9-5cba-42eb-a70a-b3e5eec9120a',
        template_title: 'Sample Parser',
        num_pages: 5,
        result_json_data: {
          field1: 'value1',
          field2: 'value2',
        },
      },
    },
  },
  type: TriggerStrategy.WEBHOOK,
  async onEnable(context) {
    // Webhook URL is automatically provided by Activepieces
    // User needs to manually configure the webhook URL in DocumentPro dashboard
  },
  async onDisable(context) {
    // User should remove webhook from DocumentPro dashboard
  },
  async run(context) {
    return [context.payload.body];
  },
});