I've only done it once, but I guess once is better than none.
First you get an active sensor ping on the race, or see a planetary population. Then they will show up in your diplomacy screen. Create a diplomacy team on one of your planets (they do diplomacy long distance, they don't have to be anywhere near who you are trying to talk to) and assign that team to the race on the diplomacy screen. Your opinion of the race (the Diplomatic rating) should slowly grow, modified by the skill of your team as well as some statistics like xenophobia and diplomacy.
It's also handy to initiate communication. You'll get a small bonus to your Diplomacy Rating for knowing their language, and you'll learn the empire's actual name instead of the generic one your intel officers gave them. You don't need a diplomacy team for that, but it can take awhile.
However it is entirely possible that you saw the empire, but they didn't see you. If you want peace you want them to know you exist as soon as you can, or all your diplomatic actions are only one sided. You may have them as friendly but they just recently noticed you exist so they could end up considering you hostile.
Turning on a transponder is good for that. All ships in the system will see the ship and identify the race associated with it (you). Once they know you exist they will assign a diplomacy team to you, which works the same way as yours does boosting their opinion of you. The skill of the other race's diplomacy team will also increase your diplomatic rating of them, and you should slowly gain ground towards peaceful coexistence.
Note that until you are listed as friendly the NPR will quickly lose DR(start disliking you) for any ships of yours they see inside one of their own populated systems. If they have a population in the system, they don't want you there. If you have a trade agreement with them they make an exception for all commercial classed ships.
Any hostile action against a ship will immediately set the DR to -150 if it is above it no matter how high. There is no way to know what DR the NPR has in regards to your empire (without developer mode). So just because the DR on your side is high enough to list them as friendly doesn't mean it is the same for them. And it takes thousands of DR to be able to call them friendly or allied, so it takes a long time. Trade agreements, and survey sharing, and research sharing gives both sides DR bonuses which can speed up the process. And every year the DR is reduced by your race's xenophobia rating.
When you are at allied the other race will automatically know the locations of all your ships, and your ships can defend the other race's ships from missiles with PD systems. Same for you when they list you as their ally.
P.S. I don't have all the information, and I don't have the various numbers related to diplomacy memorized, like exactly what DR makes what diplomacy options available, or how much ships in a system hurt diplomacy or stuff like that.
P.S.S. It is impossible to become completely friendly with Star Swarm or Precursors. Even if you somehow manage to get them up to the higher DRs they will always consider alien ships as hostile.