A nucleophile is a species (an ion or a molecule) which is strongly attracted to a region of positive charge in something else. Nucleophiles are either fully negative ions, or else have a strongly - charge somewhere on a molecule. Ammonia obviously doesn't carry a negative charge. However, nitrogen is more electronegative than hydrogen, and so the nitrogen atom carries some degree of negative charge. It also has an active lone pair of electrons. The attack on the + carbon atom in the halogenoalkane is by this lone pair on the nitrogen atom.