Live Agent Sensitive Data Rules

After implementing Live Agent, you may find yourself scratching your head at how to write patterns to prevent sensitive data from being sent over chat. Sure you can just type in strings, but you’ll quickly realize that strings aren’t good enough. The documentation says it supports JavaScript Regex statements, but doesn’t provide much information beyond that. I found Mozilla’s¬†documentation to be the best at helping me with the patterns.

Here are a few patterns that I think you might find helpful. They might not let you Make America Kittens Again, but you can still have some fun with it.

  1. Naughty words case insensitive: you might want to prevent certain bad words to be sent, but quickly realized that case is important in these patterns. for example, you can block “ass”, but what about “Ass” or “ASS” or even “AsS”? Use square brackets to group the two cases together like so:
  2. Naughty words with drawn out vowels. Sometimes people like to repeat vowel sounds in curse words. We can block those too using {n,} where n is a number and the comma means at least that many occurrences of the preceding letter. You can also use the square brackets like in the above example to use character substitutions.
  3. Credit card numbers or Social Security numbers: credit card numbers are either 15 or 16 characters long and are predictable with what number they start with (Amex starts with 3 and 15 long, Visa starts with 4 and is 16 long, etc). Use \d to look for any number and then {n} to tell it how many digits there are (replace n with a number). Use * for optional characters so you can look for strings such as the hyphen between the numbers.
  4. Match whole words only. Maybe you have a word you want blocked when it is used by itself, but it wouldn’t make sense to mask it when part of another word. Let’s say you are anti-fun. you can use \b for word boundaries. In this case I’m using it before and after the string so it has to stand alone, but you can also drop one of them so the match is at the end or beginning of a word only
  5. Blocking strings at the beginning or end only. I can’t think of a great use case, but you can use ^ for beginning and $ for end.
  6. Edit: after a silly back and forth on Twitter with @EvilN8, I had to add one more. This illustrates how complicated you can make things to try and prevent it from masking things you don’t mean to. And I didn’t even get all the possibilities with this one either.

2 thoughts on “Live Agent Sensitive Data Rules”

Leave a Reply