Dialogues at rest (when the player hits the "rest" button) are scripted via the "npcnameD.bcs". The "D" for dream dialogues is actually a script, not a dialogue file, although it is assigned to the pdialog in the tp2. Just create (and compile) a d.baf named as you assigne it via tp2, and put a trigger script block with the dialogue conditions into it. Then the dialogue will be triggered upon rest, if the conditions are met.
Have a look at the romance coding tutorial here, too:
Romance Authoring Tutorial, under "Sleep Scripts"
Note: For this, do not use the "splitted" method introduced in
"How to ensure your banters always run when you want them to. " (for all other NPC-initiated dialogues, I recommend it very much as it helps to prevent stuttering).