Sofia Vergara is getting animated and heading back to school as a new character on long-running cartoon series "The Simpsons."

The "Modern Family" star has been cast as teacher Mrs Berrera, who Bart Simpson starts to develop feelings for as he goes through early puberty.

The show’s executive producer, Al Jean, says of the character, “She pays special attention to him.” Bart and his school head Principal Skinner subsequently become love rivals as they vie for Mrs Berrera’s affections.

Jean tells Entertainment Weekly, “We thought it’d be interesting if both Bart and Skinner have a crush on the same woman. She feels Skinner is a wounded soul that she wants to take care of.” Vergara’s episode, titled "Teenage Mutant Milk-Caused Hurdles," is set to air as part of the upcoming 27th season, and Jean reveals the actress could be back for future episodes: “(Vergara) was really funny and we were glad to have her."

Vergara, who previously voiced characters for "Family Guy" and "The Cleveland Show," shoots "Modern Family" just steps away from "The Simpsons'" studios.

This article originally appeared on News.com.au.