The 'Add Pop-up Note' functionality is a MacroScript which you can freely examine. When you go to Customize User Interface, right-click the 'Add Pop-Up Note' command and select Edit Macro Script.
You can then see exactly how it's done.
In this case it is done with a persistent #filePostOpen callback:
callbacks.addscript #filepostopen "Execute Note_NoteString" id:#SceneNote persistent:true
A persistent callback is one which is saved inside the scene file.