Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmail trigger On Message Received triggers when a draft is created #9204

Open
LucBerge opened this issue Apr 23, 2024 · 3 comments
Open

Gmail trigger On Message Received triggers when a draft is created #9204

LucBerge opened this issue Apr 23, 2024 · 3 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@LucBerge
Copy link

LucBerge commented Apr 23, 2024

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

  1. Create a workflow with a gmail trigger + create draft response to this email
  2. Send a message to the email address
  3. 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 contains DRAFT
  • 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)

@Joffcom
Copy link
Member

Joffcom commented Apr 24, 2024

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.

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Apr 24, 2024
@LucBerge
Copy link
Author

LucBerge commented Apr 24, 2024

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?


  1. In the props filters, there is field called includeSpamTrash, we should add a prop called includeDraft (default set to false)
{
  displayName: 'Include Draft',
  name: 'includeDraft',
  type: 'boolean',
  default: false,
  description: 'Whether to include DRAFT messages in the results',
},
  1. In the prepareQuery, we should add a -in:draft in the search parameter if includeDraft set to false.
if (!qs.includeDraft) {
  if (qs.q) {
    qs.q += ` -in:draft`;
  } else {
    qs.q = `-in:draft`;
  }
  delete qs.includeDraft;
}

@Joffcom
Copy link
Member

Joffcom commented Apr 24, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

2 participants