Polling Trigger​Polling ​Trigger

Trigger flows automatically by polling external systems for new data or events.

Polling triggers repeatedly check an external system at a fixed interval. When new data or events are detected, they automatically start a new flow execution.

Kestra provides polling triggers for a wide variety of systems, including databases, message queues, cloud storage, and FTP servers.

The polling frequency is controlled by the interval property. When triggered, the flow has access to the polling results through the trigger variable, making the retrieved data immediately available for downstream tasks.

Example

For example, the following flow polls a PostgreSQL table every 5 minutes. When new rows are available, it deletes them (to prevent duplicate processing) and logs the retrieved values.

yaml
id: jdbc-trigger
namespace: company.team

inputs:
  - id: db_url
    type: STRING

tasks:
- id: update
  type: io.kestra.plugin.jdbc.postgresql.Query
  url: "{{ inputs.db_url }}"
  sql: DELETE * FROM my_table

- id: log
  type: io.kestra.plugin.core.log.Log
  message: "{{ trigger.rows }}"

triggers:
  - id: watch
    type: io.kestra.plugin.jdbc.postgresql.Trigger
    url: myurl
    interval: "PT5M"
    sql: "SELECT * FROM my_table"

In Enterprise Edition, you can assign polling triggers to a specific Worker Group using the workerGroup.key property. This allows you to control where the polling is executed.

Enterprise Example

In Enterprise Edition (Kestra 0.24+), the Salesforce Trigger enables flows to start automatically when new records are created in Salesforce. For example, the flow below sends a Slack notification whenever a new contact is added.

yaml
id: salesforce_contact_trigger
namespace: company.sales
tasks:
  - id: notify_sales_manager
    type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
    url: "{{ secret('SLACK_WEBHOOK_URL') }}"
    messageText: "New contact created" 

triggers:
  - id: new_contact_trigger
    type: io.kestra.plugin.ee.salesforce.Trigger
    interval: "PT5M"
    connection:
      username: "{{ secret('SALESFORCE_USERNAME') }}"
      password: "{{ secret('SALESFORCE_PASSWORD') }}"
      authEndpoint: "{{ secret('SALESFORCE_AUTH_ENDPOINT') }}"
    query: "SELECT Id, FirstName, LastName, Email, Phone, Company, CreatedDate FROM Contact WHERE CreatedDate >= LAST_N_MINUTES:5"

Was this page helpful?