Add a label to a task with labels in Todoist

I’m trying to add a label to a task that already has labels, but I can’t manage to work it out, I don’t know if it’s my limited knowledge of JavaScript or Pipedream’s functionality that I’m not getting.

I’m using Todoist “update_task” step, with optional field “Labels”. When I use {{steps.trigger.event.labels}} it works in not changing the labels of the task, as expected, but when I try adding a label using {{steps.trigger.event.labels.push(‘Process’)}}, it gives me “labels must be an array of labels” error. If I use {{steps.trigger.event.labels}}.push(‘Process’) it gives me the same error. I’ve already tried JSON.stringify() with different setups, and non of it seems to work.

If anyone could guide me, I would appreciate. Thanks.

Ok, I’ve finally got it. The push() method returns the length of the array, and I just had to change to concat() method. The final expression is {{steps.trigger.event.labels.concat(‘LABEL NAME’)}} for those who are struggling too.

1 Like