Mayor Bill de Blasio waded Wednesday into the Twitter spat between his Department of Transportation and City Council Speaker Melissa Mark-Viverito, calling it “stupid” that the agency had told her to call 311 with her safety complaint.

“They should recognize if the speaker of the City Council — one of the leaders of city government — is raising an issue, that obviously that demands respect and demands attention,” de Blasio, a Democrat, told reporters at an unrelated Upper West Side event.

A day earlier, Mark-Viverito (D-East Harlem) had tweeted to the New York City Department of Transportation a photo of a broken pedestrian signal that threatened to fall onto the street in her district.

The agency via Twitter responded that crews had been notified, but added, “For fastest response, pedestrian or traffic signal issues should always be reported immediately by calling 311.”

Mark-Viverito appeared to be taken aback by the seemingly dismissive response.

“I’m sorry . . . whaaaat???” she tweeted. “This a joke? Or an auto response? Or maybe even an intern? Not a response for an elected.”

De Blasio said any concerned citizen — elected official or not — should have received a courteous reply.

“I think the response should always be there we’re going to fix the problem right away,” he said.

He noted that the signal was fixed within a couple of hours, but called the episode a “teachable moment.”

The mayor said he has not spoken directly to the agency, but expected they would “get the message” through the press.

Department of Transportation spokesman Scott Gastel did not directly address de Blasio’s comments, but said the agency’s Twitter account comments are not automated. He added that Mark-Viverito’s staff reached out to the department Tuesday morning and workers had completed the repairs even before the speaker posted her tweet.