I understand the scenario, thank you. Something similar was discussed here:
Depending on which Document Builder you are willing to use, I recommend passing variables as arguments for your script.
For instance, Web Document Builder allows using arguments like that:
Here is the article about arguments usage for stand-alone version of Document Builder: Using command line arguments | ONLYOFFICE