Keywords Scraper

darronf
Tera Expert

I've created an inbound action to fire for new emails that contain certain keywords in the subject or body.  It's working correctly for words included in the subject, but it's not firing off the response email when words are in the body.  What am I missing??

 

 

(function executeRule(current, previous) {
    var keywords = ['attack', 'bruteforce', 'brute-force', 'brute force', 'click', 'infect', 'malware', 'phish', 'trojan', 'virus'];
    var subject = current.subject.toLowerCase();
    var htmlEmail = current.body_text.toLowerCase();
    var textEmail = current.body_html.toLowerCase();

    var containsKeyword = false;
    for (var i = 0; i < keywords.length; i++) {
        if (subject.includes(keywords[i]) || htmlEmail.includes(keywords[i]) || textEmail.includes(keywords[i])) {
            containsKeyword = true;
            break;
            }
        }

    if (containsKeyword) {
        gs.eventQueue('notify.caller.from.incident', current, '', '');
        }
    }
)

(current, previous);

 

1 ACCEPTED SOLUTION

darronf
Tera Expert

Found the answer.  Looks like I was drilling down too far for the rule to operate correctly.  I only needed to refer to 

current.body

with no _text or _html.  Scraper is working correctly now.

View solution in original post

2 REPLIES 2

darronf
Tera Expert

Found the answer.  Looks like I was drilling down too far for the rule to operate correctly.  I only needed to refer to 

current.body

with no _text or _html.  Scraper is working correctly now.

Peressildur
Tera Contributor

I ran into a similar issue when setting up inbound actions, and it turned out the problem was with how the trigger was configured to check the body text. In my case, it was only scanning the subject by default, so I had to adjust the conditions to also look through the email body. Once I made sure it was set up to scan both, everything worked perfectly! I also used a little automation on my end to help with form submissions, and I found that submit form with puppeteer really helped automate a part of the process for me. It made everything smoother and less manual.