There is an increasing interest to realize smarter sensors and actuators that can deliver a multitude of sophisticated functionalities while being compact in size and of low cost. We report here combining both sensing and actuation on the same device based on a single microstructure. Specifically, we demonstrate a smart resonant gas (mass) sensor, which in addition to being capable of quantifying the amount of absorbed gas, can be autonomously triggered as an electrical switch upon exceeding a preset threshold of absorbed gas. Toward this, an electrostatically actuated polymer microbeam is fabricated and is then functionalized with a metal-organic framework, namely, HKUST-1. The microbeam is demonstrated to absorb vapors up to a certain threshold, after which is shown to collapse through the dynamic pull-in instability. Upon pull-in, the microstructure can be made to act as an electrical switch to achieve desirable actions, such as alarming.