Chapters 1-2 of the Book of Job begin by setting the stage in heaven for the earthly events to follow.
You can access these chapters (in the World English Bible) in a new tab, so you can switch back and forth easily:
The first 2 chapters, and the latter half of the final chapter (42) form a framework for the lengthy poetic debate sandwiched in between. Some scholars believe these framing chapters may have been written separately or at a different time from the intervening 39-chapter debate between Job and his friends.
Scholars also question whether the Book of Job may have been intended as a drama or play, which is somewhat difficult to discern when simply reading the book, but immediately evident when listening to an audio recording. Free recordings are available at Bible Gateway, in various translations and languages.
Surely Job was clearly unaware of the heavenly discussion between Satan (the Accuser) and God, at least at the time his sorrows were taking place.