We present a general framework for automatic continuity results for groups of isometries of metric spaces. In particular, we prove automatic continuity property for the groups of isometries of the Urysohn space and the Urysohn sphere, i.e. that any homomorphism from either of these groups into a separable group is continuous. This answers a question of Ben Yaacov, Berenstein and Melleray. As a consequence, we get that the group of isometries of the Urysohn space has unique Polish group topology and the group of isometries of the Urysohn sphere has unique separable group topology. Moreover, as an application of our framework we obtain new proofs of the automatic continuity property for the group $\text{Aut}([0,1],\unicode[STIX]{x1D706})$, due to Ben Yaacov, Berenstein and Melleray and for the unitary group of the infinite-dimensional separable Hilbert space, due to Tsankov.