Skip to main content

What are Triggers?

Triggers are the starting point of automation flows. They listen for events and start flow executions when those events occur. Every flow must begin with a trigger. Examples:
  • New message posted in Slack
  • New file uploaded to Google Drive
  • New issue created in GitHub
  • New row added to database

Trigger Types

Activepieces supports three types of triggers:

Polling

Periodically check for new data

Webhook

Receive real-time notifications

App Webhook

Platform-level webhook handling

Creating a Trigger

Use the CLI to generate a trigger:
You’ll be prompted for:
  • Piece name: Which piece to add the trigger to
  • Trigger name: Unique identifier (e.g., new_message)
  • Display name: Human-readable name (e.g., New Message)
  • Description: What event the trigger watches for
  • Trigger type: Polling, Webhook, or App Webhook

Polling Triggers

Polling triggers check for new data at regular intervals (e.g., every 5 minutes).

Example: New RSS Items

Polling Trigger Configuration

TriggerStrategy.POLLING
required
Set trigger type to polling
function
required
Called when user enables the trigger. Use to initialize state.
function
required
Called when user disables the trigger. Use for cleanup.
function
required
Called periodically to check for new data. Return array of new items.

Webhook Triggers

Webhook triggers receive real-time notifications from external services. They provide instant execution when events occur.

Example: New GitHub Issue

Webhook Trigger Configuration

TriggerStrategy.WEBHOOK
required
Set trigger type to webhook
function
required
Register the webhook with the external service.
function
required
Unregister the webhook.
function
required
Process incoming webhook payload. Return array of events.

App Webhook Triggers

App webhooks use platform-level webhooks shared across all users. The platform manages webhook registration automatically.

Example: Slack New Message

packages/pieces/community/slack/src/lib/triggers/new-message.ts

App Webhook Configuration

For app webhooks, you also need to configure event processors in the main piece:
src/index.ts

Trigger Context

The context object in triggers:

Deduplication

Prevent duplicate events from triggering flows multiple times:
The platform will automatically filter out items with duplicate keys.

Testing Triggers

1

Create Test Flow

Add your polling trigger to a new flow
2

Configure Properties

Fill in required properties
3

Click Test

The test function (or run if no test function) will execute
4

Check Output

Verify the trigger returns expected data

Best Practices

Store state to track processed items:
Always return an array, even if empty:
Use dedupe keys to prevent duplicate executions:
Always clean up in onDisable:
Sample data helps users understand the trigger output:

Trigger Type Comparison

Next Steps

Properties Guide

Learn about all property types

Testing

Write tests for your triggers