Schedule icon
Solve icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

Timefold Solver Feasibility Gate

Gate Timefold Platform optimization solves on hard constraint violations and alert Slack when a schedule or route is infeasible.

Categories
BusinessData

An optimized schedule or route plan that silently breaks a hard constraint, like double-booking an employee or missing a required skill, is worse than no plan at all, because it looks solved. This blueprint submits a dataset to the Timefold Platform, waits for the solver, and gates the result on its own reported score: any hard constraint violation pages Slack instead of letting the solution flow downstream unreviewed.

How it works

  1. submit_and_solve (io.kestra.plugin.timefold.Solve) submits model_input_json to the selected model_type with wait: true, so the task blocks until the Timefold Platform finishes solving and returns jobId, solverStatus, and score. fetchType: NONE skips the full modelOutput since this gate only inspects the score. allowFailure: true means a connection or authentication failure still lets the flow continue instead of aborting.
  2. classify_solution_feasibility (io.kestra.plugin.core.debug.Return) checks whether outputs.submit_and_solve.score is defined; if not, UNREACHABLE. Otherwise it checks whether the score string starts with 0hard (Timefold's score format is {hard}hard/{medium}medium/{soft}soft), returning FEASIBLE or INFEASIBLE.
  3. route_by_feasibility (io.kestra.plugin.core.flow.Switch) branches on that string: FEASIBLE logs a quiet confirmation, INFEASIBLE pages Slack with the job id and score, UNREACHABLE pages Slack separately, and defaults logs the raw outcome.
  4. log_audit_status records a status line on every run regardless of branch, so the execution history is a continuous feasibility trend.
  5. The errors block pages Slack separately if the flow itself fails outright.
  6. The timefold_feasibility_gate_schedule trigger polls every 6 hours with explicit input overrides, shipped disabled: true until you add a real API key and dataset.

What you get

  • A solve-and-gate check with zero custom polling code; the task itself waits for the solver.
  • A three-way status output (FEASIBLE / INFEASIBLE / UNREACHABLE) you can chart or gate other flows on.
  • A Slack page naming the job id and the exact score behind an infeasible solution.
  • A separate failure channel for the gate flow itself, plus a standing audit log line per run.

Who it's for

  • Operations and workforce-planning teams who generate schedules or routes with Timefold and want an automatic check before publishing a plan.
  • Platform teams who want a feasibility audit trail for every solve, not just the ones someone remembers to check manually.

Why orchestrate this with Kestra

Calling the Timefold API from a script gets you a score once; this flow makes that score load-bearing. Every solve is recorded in the execution history, the feasibility check becomes a typed output other flows can depend on, and the Switch branch is one edit away from real remediation (blocking publication, re-submitting with relaxed constraints, opening a ticket) instead of a one-off check.

Prerequisites

  • A Timefold Platform API key with access to the selected model, created at timefold.ai. baseUrl defaults to the managed cloud (https://app.timefold.ai) and can be overridden for a self-hosted Timefold deployment; no standalone open-source Docker image exists for the managed Platform API this blueprint targets, and the plugin's own documentation does not state whether a free tier exists, so treat API access as UNVERIFIED without checking current Timefold pricing.
  • A Slack incoming webhook for the infeasible and unreachable alerts.

Secrets

  • TIMEFOLD_API_KEY: Timefold Platform API key, sent as the X-API-KEY header.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used for the infeasible alert, the unreachable alert, and the flow-failure alert.
  • OSS note: if your Kestra instance reads secrets from environment variables instead of a secrets backend, set SECRET_TIMEFOLD_API_KEY and SECRET_SLACK_WEBHOOK_URL as base64, for example echo -n "<your-api-key>" | base64 and echo -n "<your-webhook-url>" | base64.

Quick start

  1. Add the TIMEFOLD_API_KEY and SLACK_WEBHOOK_URL secrets.
  2. Set model_type and model_input_json to a real dataset for your model.
  3. Run the flow once and confirm status reads FEASIBLE for a valid dataset.
  4. Enable timefold_feasibility_gate_schedule.

How to extend

  • Parse the medium and soft components of the score too, and classify a WARNING tier for solutions that are feasible but score poorly on soft constraints.
  • Add a remediation task that re-submits the dataset with wait: false and a longer solveDuration when a first attempt is infeasible.
  • Loop over several datasets with a Loop task to gate an entire batch of schedules or route plans in one run.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.