Can i run a n8n workflow from external program of my own?

Hi Team,

I started n8n recently and I am happy using it. The product was amazing and I am building few workflows on it.

Q1) I have build a simple workflow in n8n and saved it. Now, can I run that workflow from any external program like python script to instantiate the workflow whenever I need it? Is that possible, Can I have any examples related to the above mentioned query.

Q2) It was working when I am working with docker, But faced few issues when running it locally.
Configuration is as follows:-
OS:- Windows 64 bit
RAM:- 20GB
version:- n8n/0.135.1 win32-x64 node-v14.17.3

Issue1:- unable to run the workflow locally
Issue2:- unable to connect to local postgres DB, error msg:-(“connect ECONNREFUSED 127.0.0.1:5432”)

So, Please do the needful.

Thanks & Regards,
Naga siva prasad

Hi @prasadkoduru9,

You can use the webhook trigger to run your workflow as needed and pass in anything you needed. There could be other options with the cli but I have not looked into that yet.

The second issue looks like your database is refusing the connection so I would double check the host and port and confirm with telnet or a db management tool that you can connect.

Hope this helps :+1:

Hey Jon,
Thanks for quick response.

Here my use case is not running it in the workflow UI.

Step 1:- I will build a multi node workflow and save that.
Step 2:- when ever there is a trigger happens in my DB from my another application, then I want to execute the saved Workflow
Like, Do I have an option to execute the workflow via an API call or something like that.

As @Jon mentioned, you can trigger the workflow from the command line (or Python, or whatever) simply by calling the webhook URL, e.g.

curl -x GET https://example.com/webhook/0ff123c4-11a3-4d45-8db4-e5b218b4ff06

Once you’ve added the webhook trigger to your workflow, it will show you the URL to use.

You can find more information about how to make the call in different languages here

Just to be complete. You can also start a workflow via CLI: