We report on the on-surface synthesis of 7 armchair graphene nanoribbons (7-AGNRs) substituted with nitrile (CN) functional groups. The CN groups are attached to the GNR backbone by modifying the 7-AGNR precursor. While many of these groups survive the on-surface synthesis, the reaction process causes the cleavage of some CN from the ribbon backbone and the on-surface cycloisomerization of few nitriles onto pyridine rings. Scanning Tunneling Spectroscopy and Density Functional Theory reveal that CN groups behave as very efficient n-dopants, significantly downshifting the bands of the ribbon, and introducing deep impurity levels associated to the nitrogen electron lone pairs.