# Automatic Actions are not triggered if created through the API

**URL:** <https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148>\
**Category:** Questions\
**Created:** [May 23, 2024, 2:38pm UTC](https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148 "2024-05-23T14:38:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stratosgear](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/stratosgear/32/1874_2.png) [@stratosgear](https://kanboard.discourse.group/u/stratosgear)\
**Post date:** [May 23, 2024, 2:38pm UTC](https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148/1 "2024-05-23T14:38:38Z")

</div>

I’m baffled!

I used the python API client to create a set of actions that change the color of the task, based in the Category (the “\Kanboard\Action\TaskAssignColorCategory” action).

The actions are properly displayed in the Kanboard interface, and I can see the database being populated too (of course). But creating or editing a task and assigning a category does NOT change the color of the task.

If I create a new Project and I manually create Categories and the realtive Action to change color based on that category, then it **does** work (for that project only).

In the beginning I thought that something on my installation (maybe a configuration or an installed plugin) was interfering, but I tried with a brand new installation (new DB, NO plugins) and the problem persists.

Any ideas on how to easily debug this, apart from going line by line through the whole hooks abstraction path?

Many thanks!

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [May 23, 2024, 6:12pm UTC](https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148/2 "2024-05-23T18:12:54Z")

</div>

Giving a tiny example would be helpful.

Are you using the correct event name (‘task.create\_update’)?

> [@stratosgear](#):
>
> … category, then it **does** work (for that project only).

Action registrations are always bound to a single project.

Further hints: Enable debug logging, maybe you can see something there.

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [May 23, 2024, 8:41pm UTC](https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148/3 "2024-05-23T20:41:10Z")

</div>

It works like a charm here.  
As soon as I assign the specified category, the tasks color changes to red.

 ![image](https://global.discourse-cdn.com/free1/uploads/kanboard1/original/2X/1/174eaa00557a2db765bfe37f001e4b6087e44c01.png)

![image](https://global.discourse-cdn.com/free1/uploads/kanboard1/original/2X/2/233f4b8bc474da959a13856bb24c6f59b7376665.png)

---

<div class="post-metadata">

**Author:** ![stratosgear](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/stratosgear/32/1874_2.png) [@stratosgear](https://kanboard.discourse.group/u/stratosgear)\
**Post date:** [May 27, 2024, 5:49pm UTC](https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148/4 "2024-05-27T17:49:53Z")

</div>

I know it is weird. This is a sample of how the new categories and actions are created.

```auto
DEFAULT_CATEGORIES = [
    {"name": "Epic", "color": "pk_ep"},
    {"name": "User Story", "color": "pk_us"},
    {"name": "Bug", "color": "pk_bg"},
    {"name": "Task", "color": "green"},
    {"name": "Specification", "color": "pk_sp"},
    {"name": "Graphical Design", "color": "pk_gd"},
    {"name": "Work Package", "color": "pk_wp"},
    {"name": "Deliverable", "color": "pk_dv"},
    {"name": "Requirement", "color": "pk_rq"},
    {"name": "Validation Plan", "color": "pk_vp"},
    {"name": "Verification Test", "color": "pk_vt"},
    {"name": "Meeting", "color": "pk_mt"},
    {"name": "Action Item", "color": "pk_ai"},
    {"name": "Feedback", "color": "pk_fb"},
    {"name": "Knowledge Base", "color": "pk_kb"},
]

    for cat in track(DEFAULT_CATEGORIES):
        cat_id = kb.create_category(
            project_id=proj_id, name=cat["name"], color_id=cat["color"]
        )

        kb.create_action(
            project_id=proj_id,
            event_name="task.create_update",
            action_name="\Kanboard\Action\TaskAssignColorCategory",
            # params={"color_id": cat["color"], "category_id": cat_id},
            params={"color_id": "purple", "category_id": cat_id},
        )

```

Do note that most of the categories are using “invalid” colors (since I was using a plugin that was allowing me to create custom colors, but I have removed ALL plugins to debug this). The Category `Task` is using `green` which IS a valid color, though.

And yes, my tests, that I expect the automatic action to kick in ARE performed in the correct project.

Maybe I need to debug harder, but it’s a bummer that I hit a wall so early in trying to customize Kanban… I’m sure there is something wrong in my current setup, but I just cannot seem to find it!

Thanks for the feedback!

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [May 27, 2024, 6:19pm UTC](https://kanboard.discourse.group/t/automatic-actions-are-not-triggered-if-created-through-the-api/3148/5 "2024-05-27T18:19:22Z")

</div>

I’m not very familiar with Python, are you sure you don’t have to quote the backslashes?

> [@stratosgear](#):
>
> `action_name="\Kanboard\Action\TaskAssignColorCategory"`
