FLOIP / flow-spec

7 stars 6 forks source link

Core.SetGroupMembership block: Allow set multiple groups at once #62

Closed jcbalmeida closed 1 year ago

jcbalmeida commented 2 years ago

In some cases it would be interesting to be able to add or remove a contact from more than one group in the same block. For example:

{
  "type": "Core.SetGroupMembership",
  "name": "AddToMultipleGroups",
  "label": "Add to multiple groups",
  "config": {
    "groups": [
      {
        "group_key": "59c2ef5d-aeff-4df3-b717-f0624f96db74",
        "group_name": "Survey Audience"
      },
      {
        "group_key": "2d5a6b73-c1d1-448d-99d6-8942dd8e4935",
        "group_name": "Unsatisfied Customers"
      }
    ],
    "is_member": true
  },
  "exits": [
    {
      "uuid": "6827500a-38b7-4dc3-803c-d2c14e961a0f",
      "name": "Default",
      "default": true
    }
  ]
}

It is even a very common case in some RapidPro flows, where a certain condition (sometimes simply the beginning of the flow) justifies categorizing the contact in more than one group.

It is perfectly possible to do the same thing by creating a block for each group, but this ends up making the flow more extensive to perform the same action N times. Does it make any sense or is it not worth the increase in block complexity?

markboots commented 2 years ago

Hi @jcbalmeida , thanks for the suggestion! I'd be in favour of this change for the benefits of:

@smn, thoughts from your team?

smn commented 2 years ago

I'm in favour of this, and while we're at it, are we open to doing the same for Core.SetContactProperty? Right now that only allows updating a single value and requires multiple blocks for multiple properties which gets cumbersome in similar ways as described here for Core.SetGroupMembership

markboots commented 2 years ago

Thanks @smn! Appreciate the parallel connection to Core.SetContactProperty. For that one, even though it could be nice to treat these the same, I have a small preference for leaving it as a single contact property:

If we look ahead to what users need, is there a strong preference for multiple properties in SetContactProperty?

markboots commented 1 year ago

In the community meeting on July 4, there was a strong recommendation to support multiple properties in the SetContactProperty block as well. Setting multiple properties in one go is an active use-case used by Turn and RapidPro flows; it would do a lot to create simpler, more interoperable flows vs. the workaround of many individual blocks. We can include this change to Core.SetContactProperty in the scope of this issue as well.