Aggregating data based on a key

Here is the output of one module in my scenario:

I want to send a single email per “Prof concerné” (Professor), aggregating the values of “Etape” (Progress), “Matière” (Subject), and “Université” (University).

For example, the email for prof3@gmail.com would be:

__
"Hello,

Here is your progress update for this week:

Université: UPC
Matière: Spé Med
Etape: A jour (< 2 jours)

Université: UPC
Matière : Spé Pharma
Etape: En retard (entre 3 et 5 jours)"
__

The other two emails will include “Etape” (Progress), “Matière” (Subject), and “Université” (University) values with no aggregation as they only have one occurence in the bundles output by the first module.

How would you advise on building the scenario after the module?

Thanks!!

1 Like

@Bennaim
Hi, I haven’t tried it, but the following post may help.

I’ll describe the process I imagine. I hope it will be helpful.

  1. summarize Output with Array Aggregator
  2. Repeater to iterate as many times as the number of Bundles.
  3. Use a Router to conditionally branch by Email Address
  4. After branching, use Text Aggregator to summarize the output.

As a concern, I think the number of ops consumed will be higher because of the number of Bundles in the Output of the screenshot you posted.

Thanks for this!

The only thing is, my screenshot is a sample example, and I’ll never know how many routing branches I would actually need. Some days the module will output 3 bundles corresponding to one professor, another day 4 bundles with another professor.

2 Likes

@Bennaim
Thank you very much.
So you are saying that you need to get the unique value from the list of email addresses from the Output you get and then run the process.

It was a bit difficult, but I created a blueprint of scenario that may be helpful. It is difficult to explain in detail in writing, so I would be happy if you take a look at the blueprint.
After extracting unique email addresses from JSON, I used the “Text Aggregator” module to get the necessary information for each email address.

blueprint_TextAggregationForEachEmailAddress.json (17.9 KB)

Thank yo so much for this!

What your scenario outputs is an aggregation of emails and corresponding values. I’m not sure how I can later be able to use that in an email module where I use the email for the recipient and the “text” in the content.

Maybe I’ll add one more element that can clarify.

I managed to get the data as follows (e.g grouping it by prof email):

What I would want now is to be able to include in each email that will be sent to each professor the content of the Array in each bundle.

For example in email 1 I would want to have :


Recipient : ilan.benhamou@diploma-sante.fr
Content :

Hello

Here is what you need to know

Matière : Biostatistiques
Etape : Très en retard (> 5jours)
Université : UPC

Matière : Biostatistiques
Etape : Très en retard (> 5jours)
Université : UPEC - L1


And for email 2 :
Recipient: pckrzn01@gmail.com

Hello

Here is what you need to know

Matière : ICM
Etape : En retard (entre 3 et 5 jours)
Université : UPC

Matière : ICM
Etape : En retard (entre 3 et 5 jours)
Université : SU

Matière : ICM
Etape : En retard (entre 3 et 5 jours)
Université : UVSQ

Matière : ICM
Etape : En retard (entre 3 et 5 jours)
Université : USPN


The challenge is that the number of collections varies for each professor and so does the length of the email.

Any clue how I should set this up?

If not no worries, I will create a new topic as the issue has evolved a bit.

Many many many thanks again! You’re a life saver and you don’t know it!

1 Like

@Bennaim
I am glad to see you have made progress!

I believe you need to add the following process after the module that is able to get the output in the screenshot you attached.

  1. Repeater module: needed to get the values from the Array in the Bundle in order. The number of iterations should be the length of the Array in the Bundle (e.g. length(Array)).
  2. Text Aggregator: Enter necessary values in the Text field for the values obtained in the first step. In doing so, use the value of i in Repeater to specify the index of the array.

Please let me know again if you stumble over the configuration details of the module.
Good luck!