Put the channel in a %variable when the dialog is created?

/command | set %test.chan $chan

And make shure you only open the dialog in a channel window.