The Mannich reaction allows placing the aminomethyl group on position 2 of the pyrrole.

Mechanism:
Stage 1. Formation of the Mannich electrophile
![]()
Stage 2. Nucleophilic attack of pyrrole on the Mannich electrophile

Stage 3. Recovery of aromaticity

Stage 4. Neutralization
