We develop a method for calculating the electron-phonon vertex in polar semiconductors and insulators from first principles. The present formalism generalizes the Frohlich vertex to the case of anisotropic materials and multiple phonon branches, and can be used either as a post-processing correction to standard electron-phonon calculations, or in conjunction with {it ab initio} interpolation based on maximally localized Wannier functions. We demonstrate this formalism by investigating the electron-phonon interactions in anatase TiO$_2$, and show that the polar vertex significantly reduces the electron lifetimes and enhances the anisotropy of the coupling. The present work enables {it ab initio} calculations of carrier mobilities, lifetimes, mass enhancement, and pairing in polar materials.