Introduction
Often when you implement « Email-To-Case » in your organisation, you will quickly be confronted with spam. Receiving a lot of spam can have an impact on your users’ time. Let’s see how we can automatically qualify incoming emails to flag them as spam and save your users time.
Requirements
To carry out the implementation you will need knowledge of the following topics:
- Flow
- Custom Metadata Type
- Email-to-Case
- Formula
Implementation
Create a Checkbox field IsSpam on the Case object
Create a Custom Metadata Type « Keyword »
This custom metadata type will contain all the keywords that we will use to search for them in the emails.
Here are some examples of keywords you can fill in
IMPORTANT: You must enter the keywords in capital letters.
To build your keyword base, you can look on the internet, many sites offer a list that you can use.
The Most Common Email Spam Words
Avoid these 250 trigger words to stop your emails going to spam
Building the flow
1.Entry conditions
Nothing special about the entry conditions for the flow
Object : Case
When : A record is Created
Conditions : Origin Equals Email
Optimize the flow for : Fast Field Updates (Before)
2.Retrieving Keywords
We first need to get the keywords from the custom metadata type Keywords__mdt and loop over this object
We get the « Label » field which we will use to search for it in the email we receive.
3.Conditions for flagging the case as spam
In order to test if each of the keywords are found in the email we have created two formulas.
Formule : UpperDescription
UPPER({!$Record.Description})
This formula will be used to uppercase the content of the email in order to test the keywords and the content in capital letters only
Example :
- « Test » == « TEST » => FALSE
- UPPER(« Test ») == « TEST » => TRUE
Formule : IsSpam
CONTAINS({!UpperDescription} , {!Loop_keywords.Label})
We will search if each item of Keywords__mdt (Loop_keywords) is present in UpperDescription
Decision IsSpam ?
Flag the case as spam
When the case is flagged « SPAM » we stop directly, we do not need to continue with the other keywords.
Now you can test it and use it to flag incoming emails as spam :)
You can also use the notion of weight for your keywords for spam and if a case that is created with an email exceeds a certain weight, you can flag it as spam.
You can see my other articles here or read the latest blog posts here