Electron-phonon interactions in two-dimensional systems: a microscopic approach