Directus Flow: Run custom function within a Flow

1.1k Views Asked by At

Good day everyone,

I am using the Docker version of Directus.

I have the following Flow:

- Cron Job > Read Data > Run Script

But I want to "Run Function" instead as "Run script" is limited and cannot "import" nor "require" external libraries on it.

I know that I can run an API Endpoint / Webhook. So basically my question is if that I can create a custom extension with an API endpoint and then run it on the Flow, or if it is possible to "Run function".

What I want to do is to run Puppeteer inside a Flow:

- Cron Job > Read Data > Loop through the "read data" returned information and run puppeteer to return information.

I hope this question is clear.

Regards.

I tried "Run Script" but for security reasons doesn't allow "import" or "require" external libraries (Puppeteer, for example).

2

There are 2 best solutions below

1
Son Nguyen Hoang On

You can just send a HTTP request to that custom endpoint I guess?

0
tobius On

Add a CSV list of trusted Node modules to the FLOWS_EXEC_ALLOWED_MODULES env var and restart your container. Now you can import those Node modules.

It's mentioned in the docs: https://docs.directus.io/self-hosted/config-options.html