The envelopes of AGB stars are irradiated externally by ultraviolet photons; hence, the chemistry is sensitive to the photodissociation of N$_2$ and CO, which are major reservoirs of nitrogen and carbon, respectively. The photodissociation of N$_2$ has recently been quantified by laboratory and theoretical studies. Improvements have also been made for CO photodissociation. For the first time, we use accurate N$_2$ and CO photodissociation rates and shielding functions in a model of the circumstellar envelope of the carbon-rich AGB star, IRC +10216. We use a state-of-the-art chemical model of an AGB envelope, the latest CO and N$_2$ photodissociation data, and a new method for implementing molecular shielding functions in full spherical geometry with isotropic incident radiation. We compare computed column densities and radial distributions of molecules with observations. The transition of N$_2$ $\to$ N (also, CO $\to$ C $\to$ C$^+$) is shifted towards the outer envelope relative to previous models. This leads to different column densities and radial distributions of N-bearing species, especially those species whose formation/destruction processes largely depend on the availability of atomic or molecular nitrogen, for example, C$_n$N ($n$=1, 3, 5), C$_n$N$^-$ ($n$=1, 3, 5), HC$_n$N ($n$=1, 3, 5, 7, 9), H$_2$CN and CH$_2$CN. The chemistry of many species is directly or indirectly affected by the photodissociation of N$_2$ and CO, especially in the outer shell of AGB stars where photodissociation is important. Thus, it is important to include N$_2$ and CO shielding in astrochemical models of AGB envelopes and other irradiated environments. In general, while differences remain between our model of IRC +10216 and the observed molecular column densities, better agreement is found between the calculated and observed radii of peak abundance.
Bibliographical note13 pages, 17 figures, 3 tables.