By, who were telephones improved? How can I know if this is right with who or should it be whom?

Turn it around. Would you say this:

Telephones were improved by he.
or
Telephones were improved by him.

Notice which one has no -m on the end and which one does.