Euclid preparation XXXVIII. Spectroscopy of active galactic nuclei with NISP