  We present an \textit{ab initio} method to calculate phonon-assisted
absorption and emission spectra in the presence of strong excitonic effects. We
apply the method to bulk hexagonal BN which has an indirect band gap and is
known for its strong luminescence in the UV range. We first analyse the
excitons at the wave vector $\overline{q}$ of the indirect gap. The coupling of
these excitons with the various phonon modes at $\overline{q}$ is expressed in
terms of a product of the mean square displacement of the atoms and the second
derivative of the optical response function with respect to atomic displacement
along the phonon eigenvectors. The derivatives are calculated numerically with
a finite difference scheme in a supercell commensurate with $\overline{q}$. We
use detailed balance arguments to obtain the intensity ratio between emission
and absorption processes. Our results explain recent luminescence experiments
and reveal the exciton-phonon coupling channels responsible for the emission
lines.
