Trying to setup a simple rule to store all PDF's that match a label
plattze opened this issue · 6 comments
Any email that has the label "Tax", I'd like to store under "Documents/tax".
Here is my config:
/* global GmailProcessor */
var gettingStartedConfigV2 = {
settings: {
// Place settings here
},
global: {
// Place global thread, message or attachment configuration here
},
threads: [
// Place thread processing config here
{
match: {
query: "label:Tax",
},
attachments: [
{
match: {
appType: "pdf",
},
actions: [
{
name: "attachment.store",
args: {
location:
"Documents/tax/${message.date:format:yyyy-MM-dd} - ${attachment.name}",
},
},
],
},
],
},
],
}
function gettingStartedEffectiveConfig() {
const effectiveConfig = GmailProcessor.Lib.getEffectiveConfig(
gettingStartedConfigV2,
)
console.log(JSON.stringify(effectiveConfig, null, 2))
}
function gettingStartedRun() {
GmailProcessor.run(gettingStartedConfigV2, "dry-run")
}
Here is the logs. It finds the email: "got 1 threads" but then immediately skips it?
11:09:32 PM Notice Execution started
11:09:33 PM Info [2023-08-22T13:09:33.201Z] INFO: Processing of GmailProcessor config started ...
11:09:33 PM Info [2023-08-22T13:09:33.204Z] INFO: Setting up action registry ...
11:09:33 PM Info [2023-08-22T13:09:33.246Z] DEBUG: ProcessingContext: {
"config": {
"description": "",
"global": {
"attachment": {
"actions": [],
"description": "",
"match": {
"contentType": ".*",
"includeAttachments": true,
"includeInlineImages": true,
"largerThan": -1,
"name": "(.*)",
"smallerThan": 9007199254740991
},
"name": ""
},
"message": {
"actions": [
{
"args": {},
"description": "",
"name": "message.markRead",
"processingStage": "post-main"
}
],
"description": "",
"attachments": [],
"match": {
"from": ".*",
"is": [],
"newerThan": "",
"olderThan": "",
"subject": ".*",
"to": ".*"
},
"name": ""
},
"thread": {
"actions": [],
"description": "",
"messages": [],
"attachments": [],
"match": {
"firstMessageSubject": ".*",
"labels": ".*",
"maxMessageCount": -1,
"minMessageCount": 1,
"query": "has:attachment -in:trash -in:drafts -in:spam newer_than:1d"
},
"name": ""
},
"variables": []
},
"threads": [
{
"actions": [],
"description": "",
"messages": [
{
"actions": [],
"description": "",
"attachments": [
{
"actions": [
{
"args": {
"location": "Documents/tax/${message.date:format:yyyy-MM-dd} - ${attachment.name}"
},
"description": "",
"name": "attachment.store",
"processingStage": "post-main"
}
],
"description": "",
"match": {
"contentType": ".*",
"includeAttachments": true,
"includeInlineImages": true,
"largerThan": -1,
"name": "(.*)",
"smallerThan": 9007199254740991,
"appType": "pdf"
},
"name": ""
}
],
"match": {
"from": ".*",
"is": [],
"newerThan": "",
"olderThan": "",
"subject": ".*",
"to": ".*"
},
"name": ""
}
],
"attachments": [],
"match": {
"firstMessageSubject": ".*",
"labels": ".*",
"maxMessageCount": -1,
"minMessageCount": 1,
"query": "label:Tax"
},
"name": ""
}
],
"settings": {
"logSheetLocation": "",
"maxBatchSize": 10,
"maxRuntime": 280,
"markProcessedLabel": "",
"markProcessedMethod": "mark-read",
"sleepTimeThreads": 100,
"sleepTimeMessages": 0,
"sleepTimeAttachments": 0
}
}
}
11:09:33 PM Info [2023-08-22T13:09:33.247Z] INFO: Processing of thread config index '0' started ...
11:09:33 PM Info [2023-08-22T13:09:33.249Z] INFO: GMail search query: has:attachment -in:trash -in:drafts -in:spam newer_than:1d label:AWS_Expenses
11:09:33 PM Info [2023-08-22T13:09:33.496Z] INFO: -> got 1 threads
11:09:33 PM Info [2023-08-22T13:09:33.689Z] DEBUG: Skipping non-matching thread id 18a1c4ffb6d69dd3 (date:'2023-08-22T08:15:15.000Z', subject:'Booking Confirmation').
11:09:33 PM Info [2023-08-22T13:09:33.690Z] INFO: Processing of thread config index '0' finished.
11:09:33 PM Info [2023-08-22T13:09:33.691Z] INFO: Processing of GmailProcessor config finished
11:09:34 PM Notice Execution completed
Thoughts?
Hi @plattze,
seems like you've used some pre-release, since I've just released version 2.0.0 a moment ago, so maybe you'd like to switch to the released version, although I do not see a reason, why the thread should be skipped.
The attachment config should be corrected in this way, but I don't think this is related to your issue:
match: {
contentType: "application/pdf",
},
Let me know, if it changes something.
Thank you,I just upgraded to 121.
It looks like it is finding the thread, but still skips it?
[2023-08-23T05:13:34.356Z] DEBUG: Skipping non-matching thread id 18a1c4ffb6d69dd3 (date:'2023-08-22T08:15:15.000Z', subject:'Booking Confirmation').
What can I try?
Apologies if I am doing something wrong, this is my first Google Apps Script.
Hi, I found a bug in the matching logic that has been fixed with 2.0.1, which is also pushed to Google Apps Script (for both Stable and Beta).
I hope this fixes your issue.
No luck sorry, version 122 still fails:
2:33:35 PM Info [2023-08-24T04:33:35.369Z] INFO: GMail search query: has:attachment -in:trash -in:drafts -in:spam newer_than:1d label:Tax
2:33:35 PM Info [2023-08-24T04:33:35.552Z] INFO: -> got 1 threads
2:33:35 PM Info [2023-08-24T04:33:35.682Z] DEBUG: Skipping non-matching thread id 18a25d19152caab2 (date:'2023-08-24T04:33:22.000Z', subject:'Test').
Config:
var gettingStartedConfigV2 = {
settings: {
// Place settings here
},
global: {
// Place global thread, message or attachment configuration here
},
threads: [
// Place thread processing config here
{
match: {
query: "label:Tax",
},
attachments: [
{
match: {
contentType: "application/pdf",
},
actions: [
{
name: "attachment.store",
args: {
location:
"Documents/${message.date:format:yyyy-MM-dd} - ${attachment.name}",
},
},
],
},
],
},
],
}
Version 124 fixed my issue, thank you.
Thanks for reporting back, closing the issue.