The answer is: issuing Germany an ultimatum and accepting the Sussex Pledge
According to the Sussex flex, Germany agreed to not attacking passenger ships in their sea warfare. Germany violated this agreement two years later because they believe that attacking passenger ships was beneficial to them since it can cut down the supplies from Allied forces.