Workflow - AI Summary from PostgreSQL Query

I am new to Workflows and am looking to implement a specific idea. I was hoping to crowd-source some ideas from more experienced users.

We have a dataset with entries for a number of different clients. Each client is tied to an email address.

I would like to query a dataset with the user emails included.

I would then like to trigger a separate AI summary of each user's data.

I would then like that summary emailed to the user.

This may seem basic, but I've struggled to use the Loop block and I know that will be integral here.

I'm also curious as to the most efficient way to "parameterize" this workflow. Should I have a client name parameter in my initial SQL query and loop through a list of eligible client names, or should I be looping later in the workflow?

Again, I'm a total novice so hopefully my goals are clear! If I can clarify anything just ask and I'll try to do so.

Hi @pod2! Thanks for reaching out. This sounds like a perfectly reasonable workflow. :slightly_smiling_face:

Here's a quick example I put together:

At a high level, this workflow fetches user data from the database and then generates a very nice compliment for each of them. One of the keys to effectively using a Loop block is understanding that each element in the input array is exposed through the value variable. Similarly, the index is exposed through the index variable. In the last block, we take advantage of this to associate each user's email with their AI-generated compliment.

If I understand correctly, you want to parameterize the workflow in order to fetch some subset of users instead of the entire dataset. Is that right? If so, you can provide a search parameter or filter via the payload of the request that you use to trigger the webhook and then reference that value in subsequent blocks.

image

I hope that helps! Definitely let me know if you have any follow-up questions.