How to execute Python or bash script after create a new record?

Hi,

I’m new to Corteza and javascript. I’m try to execute an external Python or bash script existing on my server after create a new record, but how can I pass the field value of record to the scripts and attach the resulting file to the record? I have read the documentation and found workflow can solve it, but I have no idea for it? Can you help me?

Feng

1 Like

well, you need to overengineer it!

Hi, munawir.
Thanks for you quick reply. Can you show me some code snippets or give me some hints about it? Any help will be as always appreciated.
Feng

execute python script as child process or as external 3rd party (api)

1 Like

Hi Munawir,

I don’t know how to execute the scripts as child process, can you show me some snippets or snapshots? Any help will be really appreciated. :pray:

Feng

you’ll create a server-script(in coredor) that runs python as child process

1 Like

Hi, munawir,
Thanks for your reply, I will try to learn it.

Feng

1 Like

Basically what @munawir said.
As far as our automation goes, you have automation scripts (JavaScript) and workflows (visual drag & drop builder).

If you’re set on using Python/bash scripts, you’ll need to invoke it from a server-side automation script. At some point we’ll consider supporting different languages but for now you can either overengineer it or move the code to JavaScript.

Hello,
I am new to Corteza.
It seems awesome with lot of flexibility, which makes my life lot easier.
Is there any milestone to implement Python for automation script?
Thanks

@shahin ,

There’s no implemented direct callout to python/bash scripts and I haven’t seen in on Corteza’s roadmap either.

There are a few ways I can think of to accomplish what you’re asking.

In my opinion the cleanest/easiest way would be to write a cloud function (using AWS lambda for example) in python, and then call it from a corteza workflow using the http step. Keep in mind that you’d need to secure the endpoint with some kind of authentication (or if possible whitelisted inbound ip addresses).

Thanks for your answer @shmuel .
It seems that I ‘have to’ do some over engineering.
To be cost effective, I am gonna selfhost python functions on other docker on same server. and invoke them with http step.
Best

That also makes sense.

Another option as mentioned here: Customize or script using golang? - #2 by darh is to implement your own automation server using python/grpc. I’m sure it would be a welcome contribution to the community but that would be a lot more work than what you’re suggesting.

Also, in my experience, simple rest web calls are easier to implement and debug than grpc (which is the protocol that the corteza server uses to communicate with the automation server)

I will stick to your first suggestion. Because I am more comfortable to do REST and also server side jobs.
Thanks for mentioning the alternative way.

1 Like