“Who” and “whom” are relative pronouns, and the trick for choosing the right one is to switch the clause around so that you can substitute a personal pronoun.