The frog could have a sensing system similar to that of a color-perceiving eye that responds to the wavelengths of light reflected onto the body. It would interpret these signals and release corresponding types of MSH to specialized skin cells in order to match the perceived colors or patterns.
Work Step by Step
This process would require the ability to interpret the environment via some sort of sensors that would send endocrine signals that in turn trigger the actual changing of skin color. There would be a few steps where the stimulus (receiving light wavelengths) would need to be interpreted and translated to different chemical signals.