Monthly triggered recurring automation is not running as expected
gassim
Hi there!
I’ve been facing an issue with an automation that is supposed to trigger at the start of the month; however, even though it is enabled it’s not automatically being triggered. I can’t find any logs or a way to debug why it’s not running on its own when it’s expected to do so. Does anyone of you know how I could resolve this issue please?
As you can see below the automation is expected to ‘Schedule a PM with Data Explorer results’ automatically every month. If I click “trigger now” it will work as expected: the users added to the list will receive the Data Explorer result as well as a CSV; however, the automatic trigger is not runninng.
I’d appreciate any feedback or suggestions that you can help me resolve this. Thank you!
❤️ 1
kairo162
Did you confirm the exact scheduled date and the time zone setting, and, if available, did you turn on the Run Missed Jobs button?
❤️ 1
putty
Have you done any tests to ensure all the criteria are being met naturally (besides trigger now)? I.e., set the timing to occur daily and go to a dummy group. If it works correctly, then shift to monthly to your actual group.
Also, I believe your target audience needs to have the data explorer query shared to them:
Yes.. but the issue is not that it’s not running at the scheduled date/time, the issue is that it’s not running at all.
Where can I find this button please?
It’s supposed to send a direct PM to two users. The users have the query shared shared to them. Thanks for the suggestion to test by trying different timing. I’ll try to experiment using a dummy group as well.
❤️ 2
Moin
The main difference I notice is that your interface doesn’t show when the automation is supposed to trigger next.
I think I would start by setting up a new automation with the same settings and checking whether that gets a ‘next trigger date’ after enabling it.
❤️ 1
Lilly
i use this exact automation script in multiple places without issue. here is what my config in one of them - i changed the recurrence to 5 minutes instead of a week for this test, but it fires weekly as expected when that is set):
maybe try removing that control knobs emoji from the script name and data explorer query title. that might be breaking the payload (although i think they should be ok).
👀 1
gassim
Hi @Moin@Lilly
Thanks for the help! I’m afraid the mystery is still not solved… here’s why:
Before the ‘trigger date’ that’s exactly how it looked with the message ‘Next automation will trigger at: [date/time]’; however, after that date/time passed without it running successfully, it doesn’t show the message. While testing, I changed the timing to 1 minute and the trigger message reappeared. On a previous month when it didn’t trigger, I updated the timer and it showed the message that it will trigger on the first hour of the upcoming month (but it didn’t).
It actually worked and got triggered on some month while it didn’t on other months so it’s not clear why, but now it seems to no longer automatically activate ever. What is the version of the Discourse you’re using? Mine is 2026.5.0-latest…
Unfortunately, even when I trigger, nothing appears in the /logs. (I’ve all options selected).
I don’t think that’s the issue because I changed the trigger to 1 minute and it got sent:
Okay, thanks! Would you like to try to create a test automation that triggers monthly please?
I have a feeling that the issue is with the ‘monthly’ trigger because when I change it to 1 minute trigger, it works.
❤️ 1
Lilly
ok i set it to a month then triggered it and it worked. but waiting a month to test isn’t really useful here. i’ll try setting the start date in a few minutes.
edit: monthly appears to be working for me
kairo162
If it’s working for you, maybe the error is only on some users?
Lilly
ok so Moin and i were chatting about this case today, and she brought up that perhaps there is a bug with using monthly because the length of a month varies? of course she was right - sort of…
anyways, i did a little more digging
i couldn’t actually find the automation script for the schedule pm with data-explorer results in core plugins/automation/lib/discourse_automation/scripts folder so it is hiding somewhere else.
but i was looking at the logic here for recurring (presumably that script is using it) in plugins/automation/lib/discourse_automation/triggers/recurring.rb:
i think the underlying code for monthly recurring automations is calculating the Nth weekday instead of the actual calendar date and there is a logic mismatch with Calendar day - that by injecting BYDAY=#{count}#{byday} into the RRule, the automation forces a day-of-week alignment, and that it should use BYMONTHDAY instead of BYDAY.
so if you set an automation to start on April 15th (which happens to be the 3rd Wednesday of April) the system interpreted the rule as: run on the 3rd Wednesday of every month.
when May rolls around, the 3rd Wednesday is May 20th, which causes the schedule to drift by 5 days.
moreover, if you set an automation on the 30th or 31st of a month (e.g., the “5th Tuesday”), the system would look for the 5th Tuesday in the following month. if that month only had 4 Tuesdays, the automation would completely fail to find a valid date and silently skip the entire month.
i have a tested fix and am making a PR if the team wants to check it out. it changes the logic from Nth Weekday to exact Calendar Date.
here are some screenshots from my testing and debugging:
2 instances, one without a fix and the other with my logic fix
create the exact same automation in both (fixed version is on the right):
check out the differences in the banners that say " Next automation will trigger at:" messages with 5 day drift - the unpatched version is drifting to the third Wednesday (May 20th), instead of May 15th.
for example, months could get totally skipped if it was looking for the 4th Thursday instead of an actual date.
can also test the same result in the rails console
edit: bug appears to be affecting any automation script using recurring trigger set to run every month.
i can repro the empty banner sometimes too, for example if one sets the start date for 2026 April 29th, then it cannot find the the 5th Wednesday for May because it doesn’t exist - the automation will fail to trigger here: (unfixed is on left, fixed on right)
it looks like the bug throws a NoMethodError in rails when it can’t find the Nth day in week like above; hence empty next trigger banner and failed run:
just noting that it occurred to me at one point during debugging that the existing behavior may be intentional (given the spec tests were configured with drifting days). however, i would argue that admins who configure this automation are likely expecting date calendar month and not Nth day month. and the skipping of months for an automation when it can’t find the Nth day of month is problematic.
edit: just added an edge case fix and spec tests for when it can’t find an exact date match for the next month, it goes to the last day of month (ie: Jan 31st → Feb 28th). also account for leap year.
❤️ 1🚀 1
gassim
Hi @Lilly
Thank you so much for looking into this. I don’t know if your fix has been merged and if it will solve the month date issue. However, I assume that if I update the trigger for each month, it should work, right?
In other words, I’d need to specifically update the trigger to that specific day each month and then it will trigger. If I understood correctly, the issue was when it wants to pick the day on its own. Hopefully your fix will fix that… saw the batch bot was giving you a challenge but hope it all goes well. Thanks once again for your help!
Thank you all! <3
Lilly
sorry my PR has not been merged and is awaiting a final review from a team member. for now, you can try updating the trigger with a different date, just make sure when you configure it that the “next trigger” message that pops up gives the correct next monthly date run.