How to create the notebook code with parameters and execute it with a command?

Here is my request: my extension has some input label with parameters and a button. After I click the button, jupyterlab will create a new jupyter notebook widget on the main tab, where the first cell shows the parameters. It would be better if the notebook executes automatically.
I tried to post a request to python service and the script created a notebook in jupyter’s root path, but the notebook can’t be found.

Perhaps see this existing discussion:

Basically: there are a number of existing commands which will give you access to some higher-level APIs.