Could well have been key to his eventual repentance too. Though we have no evidence one way or another, so I’ll just leave that as a ‘maybe.’
Some dreams are clearly sent by God We are told in the last days young men will see visions and old men will dream dreams. In addition God warned people in dreams or revealed truth to them. Those who received the dreams clearly knew they were from God so something had to be different about those dreams. I think for the most part dreams are just dreams, but God can and does communicate through dreams at times.