Transferring Range Values From Google Sheets Monthly

Hi,

I have an AI agent that interacts with users on WhatsApp and saves each conversation in a Google Sheet document. At the beginning of each month, I want to collect the data, organize it so that each conversation is linked to the relevant user, and then send it to a custom GPT.

My issue is with collecting and organizing the data.

Below I will describe in detail what my actions are and where it’s a challenge for me.

Step 1

The data is collected in the Sheet each time there is an interaction between a user and the agent. Notice how the conversations are sorted by date and not user.

Step 2 - Here is my challenge

Every month, on the first day, I want to pull the conversation data of only the prior month and organize it, so that each user ID has the full conversation linked to it.

I can use the “Get Range Values” and schedule it for the first day of each month, but how can I filter the range according to the month? And what would be the best way to organize the data?

Step 3

The organized data is sent to my custom GPT.

Thank you!