When someone tells me that they or their partner are pregnant, my typical response is "Congratulations!"

But I have found out that this remark is not always appropriate- notably when the pregnancy is unplanned. Sometimes I am informed about the pregnancy via text or online chat so it is harder to get a read on their feeling towards it. In some cases I do not know the person very well either so I do not know if I would expect them to be excited or distressed about the news. 

I feel awkward thinking about asking ["Was the pregnancy planned?"](https://interpersonal.stackexchange.com/questions/2223/is-it-rude-to-ask-if-a-pregnancy-was-planned) or "How are you feeling about it?"

Specific examples:   

> 
> "So I'm pregnant." / "Oh, congrats!" / "No, not good..." / "Oh..."  
> 
>  "Just found out that I'm pregnant." / "Oh, congrats!" / "I... I'm not
>  sure what to do."   
>  "Oh yeah- (partner's name) is pregnant." /
>  "Really? Congratulations!" / "..." / "..."  
>  "omg
>  guys im pregnant" / "congrats!!" / "no I'm SO F\*\*\*ED"
> 
> 
> 

In all my personal cases I was not informed prior that the person/couple were "trying for a baby".

**What is generally a polite or appropriate response when someone informs me of their or their partner's pregnancy if I can't get a read on their emotions?**

Not sure if it is relevant for context but I am a 24 year old living in America.