Triggers
Windmill scripts and flows can be triggered in various ways.
On-demand triggers:
- Auto-generated UIs
- Customized UIs with the App editor
- Trigger from flows
- Workflows as code (scripts only)
- Schedule
- Command-line interface (CLI)
Triggers from external events:
- API & Webhooks, including from Slack
- Emails
- Custom HTTP routes
- Websocket triggers
- Kafka triggers
- Scheduled polls
On-demand triggers
Auto-generated UIs
Windmill automatically generates user interfaces (UIs) for scripts and flows based on their parameters.
By analyzing the main function parameters, it creates an input specification in the JSON Schema format, which is then used to render the UI. Users do not need to interact with the JSON Schema directly, as Windmill simplifies the process and allows for optional UI customization.
This feature is also usable directly in the script editor to test a script in the making:
Customized UIs with the App editor
Windmill provides a WYSIWYG app editor. It allows you to build your own UI with drag-and-drop components and to connect your data to scripts and flows in minutes.
You can also automatically generate a dedicated app to execute your script.
Trigger from flows
Flows are basically sequences of scripts that execute one after another or in parallel.
Flows themselves can be triggered from other flows. This is called inner flows.
Workflows as code
Flows are not the only way to write distributed programs that execute distinct jobs. Another approach is to write a program that defines the jobs and their dependencies, and then execute that program within a Python or TypeScript script. This is known as workflows as code.
Schedule
Windmill allows you to schedule scripts using a user-friendly interface and control panel, similar to cron but with more features.
You can create schedules by specifying a script or flow, its arguments, and a CRON expression to control the execution frequency, ensuring that your tasks run automatically at the desired intervals.
CLI (Command-line interface)
The wmill
CLI allows you to interact with Windmill instances right from your terminal.
Trigger from API
Windmill provides a RESTful API that allows you to interact with your Windmill instance programmatically.
In particular, the operation run script by path is designed to trigger a script by its path, passing the required arguments.
It's an efficient way to run a script from another script.
Triggers from external events
Webhooks
In Windmill, webhooks are autogenerated for each Script and Flow, providing either asynchronous or synchronous execution modes. You can use preprocessors to transform the incoming webhook payload before it reaches your script or flow.
These webhooks accept incoming HTTP requests, allowing users to easily trigger their Windmill scripts and flows from external services by simply sending a POST request to the appropriate authentified webhook URL (requires passing a token as Bearer or query arg). Their purpose is to have the script run when it receives an input from its associated webhook.
Using webhooks, you could also trigger a script from other scripts.
Webhooks: trigger scripts from Slack
One use case of webhooks is building a Slackbot with Windmill.
Windmill uses Slack to trigger scripts and flows by establishing Slackbots and creating specific commands. By connecting Slack with Windmill, parsing incoming Slack commands, and leveraging Windmill workflows, operational teams can trigger complex automations directly from Slack.
Emails
Scripts and flows can be triggered by email messages sent to a specific email address, leveraging SMTP. Preprocessors can be used to parse and transform the email content before it's processed by your script or flow.
Custom HTTP routes
Windmill allows you to define custom HTTP routes for your scripts and flows. You can use preprocessors to transform incoming HTTP requests, handling headers, query parameters, and path parameters before they reach your script or flow.
Websocket triggers
Windmill can connect to websocket servers and trigger runnables (scripts, flows) when a message is received. Preprocessors can transform the websocket message data before it's passed to your script or flow.
Kafka triggers
Windmill can connect to Kafka brokers and trigger scripts or flows when messages are received on specific topics. This enables real-time processing of events from your Kafka ecosystem. Preprocessors can transform the Kafka message data before it reaches your script or flow.
Scheduled polls (Scheduling + Trigger scripts)
A particular use case for schedules are Trigger scripts.
Trigger scripts are used in Flows and are designed to pull data from an external source and return all of the new items since the last run, without resorting to external webhooks. A trigger script is intended to be used as scheduled poll with schedules and states (rich objects in JSON, persistent from one run to another) in order to compare the execution to the previous one and process each new item in a for loop. If there are no new items, the flow will be skipped.
You could set your script in a flow after a Trigger script to have it run only when new data is available.