Dynamic values on a Audiences?

We have a SaaS product where we have many companies and each company will have many projects.

We are playing with Audiences and Preferences and it looks like we need to create a Audience for each of the company in our system.

// Audiences ID = `company-CompanyOneID`
{
  "operator": "INCLUDES",
  "path": "company_ids",
  "value": "CompanyOneID"
}
await courier.send({
  message: {
    to: { audience_id: 'company-CompanyOneID' },
    template: '123456',
    data: req.body,
  },
  routing: { method: 'all', channels: ['direct_message', 'push', 'email'] },
});
// User Profiles
{
  "profile": {
    "id": "JoeID",
    "email": "joe@company-one.com",
    "company_ids": ["CompanyOneID"],
    "project_ids": ["project_1", "project_3", "project_7"]
  }
}
{
  "profile": {
    "id": "SamID",
    "email": "sam@company-one.com",
    "company_ids": ["CompanyOneID"],
    "project_ids": ["project_1", "project_200"]
  }
}

What I am struggling with is how should we send notifications to users when a project changes. On the profiles we will keep track of what projects the user wants to be notified on.

// Audiences ID = `user-projects-CompanyOneId`
{
  operator: 'AND',
  filters: [
    {
      operator: 'INCLUDES',
      path: 'company_ids',
      value: "CompanyOneID",
    },
    {
      operator: 'INCLUDES',
      path: 'project_ids',
      value: 'project_1', // <-- Could this be dynamic when a Audience is triggered
    },
  ],
}
await courier.send({
  message: {
    to: {
      audience_id: 'user-projects-CompanyOneId',
      // It would be nice to send a dynamic value with this Audience.
      // Or if we could send a dynamic Audience Operator.
    },
    template: 'abcdefg',
    data: req.body,
  },
  routing: { method: 'all', channels: ['direct_message', 'push', 'email'] },
});

There is two ways I can think of but there must be a better way?

  1. Create an Audience for every project that needs a notification or create a Audience for each profile and update it when the user adds/removes projects. (These seem like a bad ideas)
  2. Right before we call courier.send on the a Audience we call courier.audiences.put and update the value for the 'project_ids' and cross our fingers nothing gets out of sync.

I have #2 working as a Proof of Concept, but I think it is a bad idea to handle hundreds of projects that way. Please help me figure out a solution.

Hey there @robert - Since Audiences and Profiles work hand-in-hand, the profiles that make up part of an audience would need to include at least the CompanyOneID. Could you please elaborate a bit more by what you mean regarding a dynamic value in your audience? It’s possible this is a feature request since audience rules are there to filter user profiles based on specific values. If a user profile changes the values that once made it part of an audience, then it can automatically fall out of an audience, and at the same time, fall into another audience. Since the audience values are the source of truth, I’m curious by how you would want those to be dynamic. Looking forward to hearing back!