Remove Thread Label
This example demonstrates the usage of the action thread.removeLabel
.
It is also used to test a possible behavioral change for certain characters in label names (e.g. -
vs. /
).
👉 Edit this example in the playground.
- Config
- Script
{
"description": "The action `thread.removeLabel` removes a label from a thread.",
"global": {
"thread": {
"match": {
"query": "from:${user.email} to:${user.email} after:${date.now:date::yyyy-MM-dd} subject:'[GmailProcessor-Test] actionThreadRemoveLabel'"
}
}
},
"settings": {
"markProcessedMethod": "custom"
},
"threads": [
{
"match": {
"query": "subject:([GmailProcessor-Test] actionThreadRemoveLabel)"
},
"actions": [
{
"name": "thread.addLabel",
"processingStage": "pre-main",
"args": {
"name": "accounting-process"
}
},
{
"name": "thread.markRead",
"processingStage": "post-main"
},
{
"name": "thread.removeLabel",
"processingStage": "post-main",
"args": {
"name": "accounting-process"
}
},
{
"name": "thread.addLabel",
"processingStage": "post-main",
"args": {
"name": "accounting-autoinvoice"
}
}
]
}
]
}
function actionThreadRemoveLabelRun() {
const config = {
description:
"The action `thread.removeLabel` removes a label from a thread.",
global: {
thread: {
match: {
query:
"from:${user.email} to:${user.email} after:${date.now:date::yyyy-MM-dd} subject:'[GmailProcessor-Test] actionThreadRemoveLabel'",
},
},
},
settings: {
markProcessedMethod: "custom",
},
threads: [
{
match: {
query: "subject:([GmailProcessor-Test] actionThreadRemoveLabel)",
},
actions: [
{
name: "thread.addLabel",
processingStage: "pre-main",
args: {
name: "accounting-process",
},
},
{
name: "thread.markRead",
processingStage: "post-main",
},
{
name: "thread.removeLabel",
processingStage: "post-main",
args: {
name: "accounting-process",
},
},
{
name: "thread.addLabel",
processingStage: "post-main",
args: {
name: "accounting-autoinvoice",
},
},
],
},
],
}
return GmailProcessorLib.run(config, "dry-run")
}
Source: actionThreadRemoveLabel.ts | Issues: #303