How do I trigger a workflow when I get a new entry into my Retool DB?

Hello fine internet denizens,

I have a Retool database with a number of entries. I would like that whenever there is a new entry that is added to a particular table, it triggers a workflow to process the contents of this new entry.

Is there an elegant solution that doesn't involve a daily/hourly trigger that checks with tags within the DB to make sure not to process the same entry twice?

Please provide a step-by-step explanation as I have no experience yet with webhooks etc

Thank you !

Doc

Hi @DocShades - are the records being added from an App? If so, you could create a workflow resource in the app that you trigger as an success event when you insert records that processes the new data with the workflow you assign.

2 Likes

I do use a cronjob / interval. I load the rows that haven’t been processed yet. You can do this by setting a column “processed” to true.

Or you can delete the row after it has been processed. For me the first option is better so I can check if it was added in the table in the first place.

If anyone has another solution, I would like to know.

I do know mssql has triggers. You can run code after insert or update on a table. Pretty sure retool database doesn’t support that.

2 Likes

@DocShades following up on @Steven_W's great comment, Retool DB does not have a native way to run code on inserts.

I am not sure about a Postgres DB, I did find a stackoverflow thread hear detailing a LISTEN/NOTIFY method in SQL syntax to trigger events.

For a workflow to run, the API endpoint needs to be hit. As highlighted above, if you are inserting to your DB from a Retool app you can definitely run a query to achieve this.

If the DB inserts are coming from another website, there are ways to add in code to trigger a workflow.

But if the DB inserts are originating from another source that you cannot add a API call to, I do not believe there is a way to run code from DB Insert events :melting_face:

1 Like