My daughter was rude.

My 12 year old daughter came home from school in a snit. I happened to have a friend over when she walked in the door. When my friend asked how things were at school, my daughter gave her a sarcastic, rude answer and slunk off to her room. I was so embarrassed. What should I have done? And what can I do to make certain that is does not happen again?