"Then Zerubbabel son of Shealtiel, Joshua son of Jehozadak, the high priest, and the whole remnant of the people obeyed the voice of the Lord their God and the message of the prophet Haggai, because the Lord their God had sent him. And the people feared the Lord." NIV translation
After an inspection of the things around them, the people realized that their priorities were messed up. They knew that God had sent Haggai to them to wake them up and they repented.
"Then Haggai, the Lord's messenger, gave this message of the Lord to the people: 'I am with you,' declares the Lord. So the Lord stirred up the spirit of Zerubbabel son of Shealtiel, governor of Judah, and the spirit of Joshua son of Jehozadak, the high priest, and the spirit of the whole remnant of the people. They came and began to work on the house of the Lord Almighty, their God, on the twenty-fourth day of the sixth month in the second year of King Darius." NIV translation
This repentance got them back into line with the priorities of God as they were able to hear the Spirit of God. This led to obedience and the work began on the temple. This same pattern is at work in the lives of God's people today; God can and will give us a message of correction to refocus our priorities on His will. If we repent and listen to the Holy Spirit, He will lead us in His perfect will.