Web Actions to trigger server-side Webhook

A method for custom Web Actions that can trigger a webhook, with related asset/entity data which is sent to a URL via POST request, this is done server side and not in relation to a users workstation or AYON installation.

Use Case:

  • Production teams that do not have AYON installed can login, manage and trigger custom processes. For example, those processes might include; movement of content, uploading to external services (work in progress sends) or viewing data size
  • Artists should work flexibly, if they are away from their workstation they can still login to the web UI and trigger processes, without the need of a full AYON installation.

Why?:

  • I don’t believe every user of AYON should have a full installation to be able to interact with shots or entities. It’s almost guaranteed that we have lots of users that will need to manage projects, but will not be using the launcher or any kind of AYON installation, it’s far too much of an overhead to manage AYON installations for such lightweight use.
  • I don’t want to write custom code that lives in every AYON installation, there are many use cases where building a separate API/backend helps with managability, scaling or general workflow.

Current Issue:
Users that do not have AYON installed, which for our company is every Production team member and all users on Mac cannot trigger processes. Those users that are on Linux, can currently trigger process locally.

I want to abstract this to our own backend (AWS Lambda) and distribute processes to workers or via Deadline, which will allow ALL users to trigger tasks and work flexibly. I need a method of sending those POST requests, without any local code being executed.

Hello,
This request is similar to what we usually receive from clients. We’d be happy to have you as a client and handle this for you.

Could you tell us more about your use cases?


As far as I know, the ExecuteResponseModel doesn’t support yet http/browser actions

But, I think you can do your requests manually and use the executor.get_server_action_response to display the results.

something like:

Example
from ayon_server.actions import (
    ActionExecutor,
    ExecuteResponseModel,
    SimpleActionManifest,
)

from ayon_server.addons import BaseServerAddon


IDENTIFIER_PREFIX = "myaddon.launch"


class MyAddonSettings(BaseServerAddon):
    # Set settings
    async def get_simple_actions(
        self,
        project_name: str | None = None,
        variant: str = "production",
    ) -> list[SimpleActionManifest]:
        """Return a list of simple actions provided by the addon"""
        output = []
        
        # Add a web actions to folders.
        label = "Trigger Simple Action"
        icon = {
            "type": "material-symbols",
            "name": "switch_access_2",
        }
        output.append(
            SimpleActionManifest(
                identifier=f"{IDENTIFIER_PREFIX}.do_something",
                label=label,
                icon=icon,
                order=100,
                entity_type="folder", # "task",
                entity_subtypes=None,
                allow_multiselection=False,
            )
        )

        return output
            
    async def execute_action(
        self,
        executor: "ActionExecutor",
    ) -> "ExecuteResponseModel":
        """Execute an action provided by the addon.
        
        Note:
            Executes CLI actions defined in the addon's client code or other addons.
            
        """

        project_name = executor.context.project_name
        entity_id = executor.context.entity_ids[0]
        
        res = False 
        
        if executor.identifier == f"{IDENTIFIER_PREFIX}.do_something":
            # Do some POST requests and return the result.
            # res = ....
            if res:

                return await executor.get_server_action_response(
                    message="Action ran successfully"
                )
            else:
                return await executor.get_server_action_response(
                    success=False,
                    message="Action failed!"
                )
        
        raise ValueError(f"Unknown action: {executor.identifier}")

Also, tagging @martin.wacker for better insights.

I actually think we are already a client (stray.london), so perhaps i’m discussing this in the wrong place…

With the example you posted above, does that execute code on the server or on the the users client? This comment leads to believe it’s still executing in client code?

Perhaps I’ll add that as a test, because if it can do that server-side then that would work well.

Use cases really are aimed at production processes, main example right now would be:

  • Sending plates and reference files to delivery partners: I want our Production teams to be able to choose which plates and reference files and press an action to trigger a process to package up the files, and move them to a new directory ready for an automated delivery.
    This cannot happen currently because Production do not have AYON installed on their Macs, and in all likelihood will never have AYON installed - so it has to occur via the WebUI and then all processing be handled by our own backend/workers

Sorry my bad, I was copying and pasting from the example here and I missed cleaning up the doc string.

Ah OK!

I’ll give something like that a try and see how it goes, still getting my head around exactly where everything is being run and how it all links - but if I can just add a small request in at this level then that would be perfect :v:

I do think that it would be handy to have that globally or built in as core functionality, but perhaps there aren’t as many users that would want/need it. My thought it to try and entice Production (or any non-artist) users to live/work in AYON so having this would help a lot.

Thanks @mustafa_jafar

1 Like

@mustafa_jafar Just to confirm, this does indeed work correctly :v:

Thank you for pointing me in the right direction!