ranmocy / gmail-automata

Automate your Gmail
Apache License 2.0
102 stars 18 forks source link

How does automata process incoming threads? Unprocessed messages only? Unread messages only? #44

Open unrstuart opened 3 years ago

unrstuart commented 3 years ago

I'm trying to figure out a good way to set up some rules because I'm having issues where I miss code review emails because bot spam causes threads to be archived. I think it comes down to a misunderstanding of the way in which automata works.

Does automata process an entire thread, even if it processed some messages in a thread before? Does it only process unread messages? Is it configurable? Is it possible to build a rule that only looks at as-of-yet unprocessed messages in a thread? Is it possible to have a rule/stage that says "once this is matched, skip all further processing of any new messages in the thread"? Is it possible to have a rule/stage that tells automata to move to the next stage in the same message in the same thread, even though the default action is to stop processing because a stage matched?

I'll probably have follow up questions based on the answers, but I figured it'd be good to start with learning more about how the whole process works to see if I can figure out how to get my desired behavior on my own.

ranmocy commented 3 years ago

Yes, it process the entire thread. See Processor.ts. The script itself doesn't have any storage, so it rely on email data to keep tracing. So it uses processed/unprocessed label to track with thread needs to be processed.

When processing a thread, it will look for all messages no older than two times of the processing windows (could be changed in your config in the spreadsheet). The default window is 5 minutes, so the script will check all messages no older than 10 minutes (but at least one, the latest), if the thread is mark as needs to be processed. The related code is here). Messages read/unread doesn't matter since it's part of the automated actions, we can't rely on that to determine if it needs processing.

"once this is matched, skip all further processing of any new messages in the thread". It will be really hard if you all future messages. Through I'm not sure, maybe you could try to add a rule to add Gmail's Muted label. So that Gmail itself may mute it automatically in the future.

For stage model, if you want to keep matching more stages, try to use the action_after_match column for your rules. See the spreadsheet note