Microorganisms are physically changed upon contact with various chemicals in their environment
Molecules stick to their surfaces and generate signals in the membrane, and trigger behavioral change.
References:
Bray, Wetware (2009), p. 8
[…] when bacteria came in contact with aspartate, they became subtly changed. They acquired an internal trace that remained even after the visible effects on swimming caused by the aspartate disappeared. This trace […] represents a sort of knowledge acquired by a cell.
There are other relevant parts on pages 16 and 17 on physical contact with chemicals causing behavioral change that have long backstories and are difficult to quote.