Abstract: The optical sensor for the detection of specific substances and refractive index changes in gaseous, liquid, solid and porous samples is composed of integrated optical elements. It consists of a waveguiding film (1) equipped with a diffraction grating (4) and applied onto a substrate (2). For the selective detection of a specific substance contained in the sample (3) a selectively chemisorbing additional layer (5) covers the film (1) at least in the grating region. The sample (3) is applied at least in the grating region either directly onto the waveguiding film (1) or onto the selectively chemisorbing additional layer (5). Chemisorption of the substance, which is contained in the sample (3) and is to be detected, to the selectively chemisorbing additional layer (5) results in a further adlayer (6) coating the waveguiding film (1).