feat: implement scheduling functionality for AgentflowV2#5971
feat: implement scheduling functionality for AgentflowV2#5971prd-hoang-doan wants to merge 12 commits intoFlowiseAI:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a robust scheduling system for Agentflows, enabling users to define recurring execution times directly within the Agentflow Start node. It provides a user-friendly interface for setting schedules via cron expressions or a visual picker, backed by a resilient backend that persists these configurations and manages their execution through either a message queue or an in-process timer. This enhancement significantly expands the automation capabilities of Agentflows, allowing for time-based triggers without manual intervention. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive scheduling feature for Agentflows, including UI for configuration, database persistence, and a backend scheduler supporting both queue and non-queue modes. The implementation is well-structured, with clear separation of concerns. I have two main points of feedback: one regarding the robustness of the cron expression validation, which could be improved by breaking down complex regex into simpler, individual validations for better readability and error prevention, and another to improve code clarity by simplifying a method signature and its call sites.
184b994 to
42595f3
Compare
|
Thanks @prd-hoang-doan for this PR. We are working on a similar request and I will be testing it this week. Will reach out to you soon. |
|
@prd-hoang-doan Thanks for implementing this, this is great. Just a few things we want addressed before we merge. I split them up into bugs that need fixing and nice-to-have follow-ups. Bugs1.
|
|
@jchui-wd Thanks for the quick and detailed feedback — I’m glad to receive it.
Please let me know if you’d prefer me to prioritize any item differently. Thanks again! |
|
@prd-hoang-doan Let's just add the disable toggle in the red box area. Thanks a lot. |
|
Thanks for this, any order is alright. We will update our CONTRIBUTING.MD with proper testing standard soon, will follow up shortly. |
42595f3 to
d13799f
Compare
|
Hey @prd-hoang-doan, we updated our Contributing.md with a testing section: Let us know if you have any questions / concerns. |
|
@jchui-wd Sure, I’ll create the unit tests following your instruction. Thanks for the update. |
- Added ScheduleQueue class for managing scheduled jobs using BullMQ. - Introduced scheduleService for creating, updating, and disabling schedules. - Integrated schedule validation and cron expression handling. - Enhanced chatflow service to manage schedules for agentflows. - Added UI components for time and day selection (TimePicker, WeekDaysPicker, MonthDaysPicker). - Updated NodeInputHandler to support new input types for scheduling. - Improved validation for schedule configurations in agentflows.
- Refactor ScheduleQueue to utilize executeScheduleJob for job execution. - Add new endpoints for schedule status retrieval and enabling/disabling schedules in chatflows. - Update chatflow service to handle schedule creation, updates, and deletions more effectively. - Introduce DatePicker component for date input in UI. - Enhance CanvasHeader to manage schedule state and toggle functionality. - Integrate schedule validation logic to ensure proper configuration before enabling schedules. - Update dependencies to include node-cron for improved scheduling capabilities.
a4eeead to
529b35d
Compare
- Seperate the utils function from schedule service. - Created comprehensive unit tests for all utility functions in `utils.test.ts`, covering various scenarios for cron expression validation, visual picker validation, and schedule resolution. - Ensured proper handling of edge cases and error messages for invalid inputs.
- Seperate the utils function from schedule service. - Created comprehensive unit tests for all utility functions in utils.test.ts, covering various scenarios for cron expression validation, visual picker validation, and schedule resolution. - Ensured proper handling of edge cases and error messages for invalid inputs.
|
@jchui-wd @harshit-flowise , I updated the pull requests based on @jchui-wd suggestion. The PR includes bug fixes (except point #4). It seems that our current logic only deletes the last sessions (I tried opening multiple profiles with the same account). Users can delete all by viewing all messages, then clicking Delete All. Besides, I also implemented nice-to-have things:
Please take your time reviewing my pull requests, and feel free to share your feedback. |
There was a problem hiding this comment.
Thanks @prd-hoang-doan for doing the changes. I think they look good
Below evidences and video of my tests in local.
Regular CRON / Visual Picker
Cron Toggle OnCron_Toggle_On.mp4
Cron_Toggle_Off.mp4
Invalid_Cron_Input.mp4
Visual_Picker_Weekly.mp4
Visual_Picker_Monthly.mp4
Visual_Picker_Hourly.mp4
Visual_Picker_Daily.mp4
Server Restart Resumes Job / MODE=QUEUE
Server Restart Resumes JobServer_Restart_Resumes_Job.mp4
Mode.Queue_Test.mp4
Toggles Off After End Date / Cannot Enable Past EndDate
Toggles Off After End DateToggle_Off_After_EndDate.mp4
Cannot_Enable_Past_EndDate.mp4
Delete Flow or Change Inputs Removes ScheduleRecord
Delete Flow Deletes ScheduleRecordDelete_Flow_Deletes_ScheduleRecord.mp4
Change_Input_Deletes_ScheduleRecord.mp4
As for #4, we can deal and follow up with this internally.
Since this is a big feature and may overlap with some other of our ongoing work, we will have additional eyes later on. We are still coordinating a few things on our end so it might take a bit longer before we can merge it in. We will keep you posted.
EDIT:
Actually seems like there is an error:
CI is failing because some date columns in ScheduleRecord and ScheduleTriggerLog use type: 'timestamp', which isn't supported by SQLite.
If you remove database configs in .env just let it run on default using sqlite you can see the error when starting the server. Can you take a look?

|
@jchui-wd Thank you for your effort to review my code, test the feature, and point out the issue. I will fix check the build on |
- Change the way to update the existing schedule to avoid typescript issue when building. - Add merge function in mockRepo in schedule service test.
|
@jchui-wd I push the latest commit to fix the issue with SQLite. I also tested with other database including mariadb, mysql as well. Please help me verify on your machine with SQLite database.
|
There was a problem hiding this comment.
Thanks for applying the fix @prd-hoang-doan.
I also noticed two small issues and just pushed a fix:
(35a5802): added nullable: true to lastRunAt/nextRunAt/endDate on ScheduleRecord (entity didn't match migration DDL), and added IScheduleRecord/IScheduleTriggerLog interfaces per codebase convention.
…erfaces - Add nullable: true to lastRunAt, nextRunAt, endDate on ScheduleRecord entity to match migration DDL and prevent runtime errors - Add IScheduleRecord and IScheduleTriggerLog interfaces to Interface.ts - Have entities implement their respective interfaces per codebase convention
| description: 'Start the workflow with form inputs' | ||
| }, | ||
| { | ||
| label: 'Schedule Input', |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Confirmed with Jocelyn that editing Start.ts affects both the legacy canvas and the agentflow UI. We'd probably delay this merge to avoid unintended impacts on downstream or merge it in a separate feature branch.
|
Thank you @prd-hoang-doan for the changes! Apologies if this is taking longer since we have to let some other PRs to get in first, but this should give us enough time to test this thoroughly |
|
@HenryHengZJ Thanks for the update — no worries at all! I understand the process, and I appreciate you taking the time to test everything carefully. |
|
@prd-hoang-doan hi again, If you have time we would like some changes to help prevent cloud apps from being overloaded. 1. Enforce minimum 1-minute cron interval
2. Schedule executions need to count against prediction quota
|
- Remove supporting cron express with 6 fields (second) - Calculate the prediction usage in cron job
|
Hi @jchui-wd, I updated two mentioned points in the latest commit. Thank you for pointing out the usage issue. |
|
@prd-hoang-doan thanks for the quick turnaround. Apologies, I have to go back on my Item Number 1 request. Instead of rejecting 6-field cron entirely, can you revert that change and replace it with a minimum interval check in? Here's the updated approach:
Item Number 2 For this I just want to make sure incase theres a bug for OSS users. Flowise OSS works without account registration, meaning the workspace and organization tables can be empty. If a user never registered an account, findOneBy returns null and the schedule crashes with "Workspace not found". Can you wrap the workspace/org lookup and quota check in a platform guard so OSS skips it entirely? Thanks again for your patience! |
|
Hi @jchui-wd, thank for your feedback, but I have some concerns below: For #2, I followed the same pattern for the function |
|
Ah I should have given more context. For Number 1, we wanted to have Although I realize this might affect But I do think it is fine since from 1s - 60s the worse iteration per So I think it is fine to have Let me know your thoughts. For Number 2, I did a double take and you're right and it is not an issue, thanks! |
…guration and validation
|
Hi @jchui-wd , I added |









Ticket:
Flowise Roadmap
Overview
Adds first-class scheduled execution for Agentflows, including UI inputs for schedule configuration and a backend scheduler that can run via BullMQ (queue mode) or an in-process timer (non-queue mode).
agentflow-schedule.mov
Changes
Database
schedule_recordschedule_trigger_logNotesRecording Demo:
Youtube: https://youtu.be/MZ1ws7XqsBg
This PR includes a new migration for the scheduling entities. Please take a look when you have time, and feel free to share any feedback if changes are needed.