Is it possible to create a task using javascript?

I am a developer and I work on a BPMN editor using bpmn.js.
I would like to create a task glossary, but for that I need to be able to create tasks using javascript.
I would like to know if the library allows you to create tasks using code or I have to modify the XML directly.
My goal would be that the user fills in a glossary and that he can add the tasks he selects in a diamgram.
Sorry for my approximate level of English.
thank you in advance.

Hi Hugo,

the ElementFactory is your friend here. Please refer to this example for guidance.

Thank you so much !
To add a name to a task I use this:
var modeling = modeler.get('modeling');
modeling.updateProperties(task, {
name: 'New name'
Is this a good practice ?