Theoretically, you could look for particular strings, but I'm not sure the effort would be worth it. The problem is twofold: Firstly, you need to define what, exactly, constitutes a vulgar/swear word (not as easy to pin down as you might think!); Secondly, you have the high likelihood that the word will be (deliberately) mis-spelled to bypass filters. As a result, you will end up with a LONG filter list, which may then impact performance.
My recommendation would be to record the chats. If an agent is using what you consider to be inappropriate language, then you have a case for user training. If it's from a customer, then you need to figure out how you will handle that.