Skip to content

[SOLVED] How can I assign a labels trough Article filters #772

Discussion options

You must be logged in to vote

Hi everyone,

I've tried by myself to make a Article filters that will assign a label when the title or content match a keyword, but definitely JavaScript make not sens at all for me..

I'm sure it will be something close to -->

var whitelist = [
  'test subject', 'blabla'
];
function filterMessage() {
  if (whitelist.some(i => msg.title.indexOf(i) != -1)) {
  msg.assignLabel(findLabelId('MyLabel'))
  } 
}

But I can't figure it out. thanks

Your script is missing fundamental part, return statement indicating whether message (modified) is actually accepted by the filter or not.

Fixed:

var whitelist = [
  'qt', 'abc'
];
function filterMessage() {
  if (whitelist.some(i => msg.title.indexOf(i) 

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
8 replies
@martinrotter
Comment options

@martinrotter
Comment options

@M1chael
Comment options

@M1chael
Comment options

@martinrotter
Comment options

Comment options

You must be logged in to vote
3 replies
@BobSquarePants
Comment options

@martinrotter
Comment options

@BobSquarePants
Comment options

Answer selected by BobSquarePants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants