“Jun is one of a group of islands of innovation in the public sector,” said Arthur Mickoleit, a researcher who until recently was a digital government adviser at the Organization for Economic Cooperation and Development in Paris. “They’re tapping into social media to improve public services.”

Jun’s embrace of Twitter did not happen overnight.

Mr. Rodríguez Salas, a career politician, was elected Jun’s mayor in 2005 — the year before Twitter was founded — after serving as deputy mayor. In 2011, he asked all town officials — from his deputy to the street sweeper — to open accounts on Twitter and send messages about their daily activities. The goal, he said, was to create greater accountability and transparency over how Jun was run. Mr. Rodríguez Salas added that he chose Twitter over Facebook because Twitter allowed quicker interactions.

Jun’s officials also started asking residents to verify their Twitter accounts at the town hall — a relatively simple process of checking people’s government IDs with their online profiles to ensure their concerns were answered online.

Officials began with basic services like public maintenance, letting people tweet when they saw a broken streetlight or a road that needed cleaning.

Mr. Rodríguez Salas said such activities built good will with residents, who at first opened Twitter accounts sporadically. But since 2013, the online activity has become almost universal as people saw how their neighbors used the service.

María José Martínez, Jun’s information technology chief, also ran courses at the community center to teach Twitter 101, such as sending direct messages and using the right hashtag during local campaigns.