How to dynamically process all records in array aggregator and send to OpenAI module?

Hi everyone,

I’m working on an automation where I fetch competitor data from Airtable (e.g., Name and Products/Services) and pass it to OpenAI for cross-analysis. While I’ve successfully set up the basics, my current issue is dynamically handling all records (whether there are 2, 5, or 50 competitors) and formatting the data properly for OpenAI.


My Current Setup:

  1. I use Airtable - Search Records to fetch all competitor records.
  2. I use Array Aggregator to group Name and Products/Services fields.
  3. I pass the aggregated data into the OpenAI module.

The Problem:

The output from my Array Aggregator doesn’t automatically account for varying numbers of competitors. I’ve hardcoded Competitor 1, Competitor 2, etc., but I need it to dynamically reference all records (whether there are 2 or 50).

What I Need Help With:

  1. How to configure the Array Aggregator to ensure all records are included dynamically.
  2. Best practices for formatting the data (e.g., iterating over arrays) to create structured input for OpenAI.

Example of What I Want:

If there are 5 competitors, I want to generate:

yaml

Copy code

Competitor Analysis:
- Competitor 1:
   Name: [Name 1]
   Products/Services: [Products 1]
- Competitor 2:
   Name: [Name 2]
   Products/Services: [Products 2]
...

This should adjust dynamically based on the number of records.

Tools I’m Using:

  • Airtable
  • Array Aggregator
  • OpenAI Module

Would love any advice, tips, or even examples of how others have tackled this problem! :blush:

Thanks in advance!

The simple way to do this is to use the JSON Aggregator module. (I’m assuming that you are passing the data to OpenAI as a text value).

You create a JSON module, copy and paste an example array, this will create the model for you.

Then you simply need to use the “Text” value from the JSON aggregator output and it should be a stringified array for OpenAI.

2 Likes

Worked like a charm. Thank you so much!

1 Like