Set up the chest, "Chest 7" as normal (from Part 1), including the switch on Page 2 set to "Chest 7 Opened".
Immediately under the third Wait command in the Event Commands, we will need to call an enemy encounter (predefined in Monster Groups in the Database). For the purposes of the demo I've created one called "Cave Monster", which is a single Orc.
So, the Event Command we need is "Enemy Encounter" (the very first one on Tab 2). Set the "Specific Monster Group" to "Cave Monster" or whatever predefined monster you want. Set the "Defeat Handler" to "Execute Custom Handler", which gives additional control over winning or losing the battle. And finally, "Disallow Escape" in the "Escape Handler" unless you want to have a specific set of commands for attempting to flee.
The completed routine should look like this (not including the basic chest opening commands from Part 1):
<>Enemy Encounter: Normal, Cave Monster : Victory Handler <>Message: Congratulations! : You beat the Monster-In-A-Box! <>Call Event: Random Contents <>Switch Operation: [0008:Chest 7 Opened] ON <> : Defeat Handler <>Game Over : EndAnd it's as simple as that.