Using Script Fields in Template Conditions

Background
I love the new To-do entity and improved Todoist integration, however I’m finding one issue that I’m trying to resolve with a script. The todo.update_item service can complete items on a list but only if they actually exist. If not, the service fails. I assume future updates to the new To Do entity will fix this small issue but, in the meantime, I would like to develop a workaround.

Example Use Case
When the Roomba bin is full, a task is added to my Todoist project to “Empty Roomba bin”. When the bin is emptied, I would like that to automatically complete the task. I figured out how to write a script/automation for a specific task, but I would like to create a reusable script with fields/variables that for other similar tasks (such as “take out the trash”, “replace HVAC air filter”, “refill aerogarden”, “clean the smoker”, “recharge/replace X batteries”, etc).

My Script
If I compare against the all_tasks attribute that the Todoist calendar entity provides, I can check for the task name. However, I am at a loss for how to use a field or variable to create a repeatable script. Below is my best attempt but I can’t get my field task_name to work properly

fields:
  task_name:
    selector:
      text: null
    name: Task Name
sequence:
  - if:
      - condition: template
        value_template: "{{ task_name in state_attr('calendar.personal_tasks','all_tasks') }}"
    then:
      - service: todo.update_item
        data:
          status: completed
          item: task_name
        target:
          entity_id: todo.personal_tasks

How do I reference a field within a template condition? I can’t seem to find any direction on this within the HA docs and I can hardly understand the Jinja docs.

Nevermind… I found my issue. It has nothing to do with my template condition. For some reason I forgot to use the curly brackets and parentheses in the update_item service. The following call works now

fields:
  task_name:
    selector:
      text: null
    name: Task Name
sequence:
  - if:
      - condition: template
        value_template: "{{ task_name in state_attr('calendar.personal_tasks','all_tasks') }}"
    then:
      - service: todo.update_item
        data:
          status: completed
          item: "{{ task_name }}"
        target:
          entity_id: todo.personal_tasks