I know the overview of HSRP and that election depends on priority. I also know that only active and standby routers send hello messages every 3 seconds. But when the routers are first configured with HSRP, how do they exchange message and elect the router with highest priority?
Cisco has many documents to explain such things. For example, Hot Standby Router Protocol (HSRP): Frequently Asked Questions:
Q. If there is no priority configured for a standby group, what determines which router is active?
A. The priority field is used to elect the active router and the standby router for the specific group. In the case of an equal priority, the router with the highest IP address for the respective group is elected as active. Furthermore, if there are more than two routers in the group, the second highest IP address determines the standby router and the other router/routers are in the listen state.
Note: If no priority is configured, it uses the default of 100.