You have to do it in the 'scripts' section. There is a tab for it. So you define the script there and then choose the object/location etc from where to call it
P.S.. I havnt worked that much with Quest5 to be sure if that is actually supported in gamebook mode as i never tried that one due to being called 'limited'.
I do recall that there is the recommandation to not use gamebook due to that but use full mode and disable some of the panes instead if one wants to create a VN.