@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
String message = event.message.getUnformattedText(); // The message recieved
if(message.contains("string")) {
Minecraft.getMinecraft().thePlayer.sendChatMessage(""); // Send message or command
}
}