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.
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.
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).
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:
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.
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 2025 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: