Add Task to board programmatically

First create the model element, then add it to the canvas:

const task = elementFactory.createShape({
  type: 'bpmn:Task',
  name: 'Foo'
});

const position = {
  x: 100,
  y: 100
};

modeling.createShape(task, position, parent);