Gmail trigger `On Message Received` triggers when a draft is created
LucBerge opened this issue · 3 comments
Bug Description
I have a workflow that triggers when a new gmail message is received. The workflow create draft response for some messages (not all).
Once the draft is created, the trigger will fire again.
To Reproduce
- Create a workflow with a gmail trigger + create draft response to this email
- Send a message to the email address
- Whatch the workflow trigger forever
Expected behavior
In the trigger node, when selecting the On Message Received
, all messages in draft must be ignored.
Temporary workaround
- Use a filter node right after the trigger and keep data where
labelIds
do not containsDRAFT
- Add the filter option
Search
and set the query value to-in:draft
Operating System
Rasbian x64
n8n Version
1.37.3
Node.js Version
docker version, idk
Database
SQLite (default)
Execution mode
main (default)
Hey @LucBerge,
Thanks for the report, I have created NODE-1315
for this but I don't believe this is a bug and it is more of a feature request.
When you create a draft email it is creating a new email which the gmail api is returning so technically it is working as expected but I am keeping this open and have created the dev ticket as it does seem like something we should add to protect users that do the same thing and to lower the execution count as on Cloud you could easily use all of your executions very quickly.
I don't believe this is a bug and it is more of a feature request.
I agree.
@Joffcom where can I track NODE-1315
?
- In the props
filters
, there is field calledincludeSpamTrash
, we should add a prop calledincludeDraft
(default set tofalse
)
{
displayName: 'Include Draft',
name: 'includeDraft',
type: 'boolean',
default: false,
description: 'Whether to include DRAFT messages in the results',
},
- In the
prepareQuery
, we should add a-in:draft
in the search parameter ifincludeDraft
set tofalse
.
if (!qs.includeDraft) {
if (qs.q) {
qs.q += ` -in:draft`;
} else {
qs.q = `-in:draft`;
}
delete qs.includeDraft;
}
@LucBerge we don't have anywhere to track the issue as it is in the internal system now but once we work on it we will pop open a PR with the issue ref and it will notify on here.
What you have put is pretty much what I was thinking but it needs to go through prioritisation then review, If you wanted to pop in a PR for it I can add it to my PR review list for tomorrow morning.