Crate training or getting a puppy pen teaches your puppy to stay in a space quietly playing or napping.
For the first few nights your puppy is home, you might want to let them sleep in your room so they are reassured they’re safe.
Make sure to be consistent about setting rules with your new puppy, so they don’t get confused or forget.