How to use Dynamic Groups to manage your contacts

April 21, 2016

We’ve already explained in this post how to use dynamic groups to create groups based on specific features such as age, gender, location, etc.

This post goes further into this feature and how it can help you organize your contacts based on features, engagement and/or missing information.

Organize contacts by feature(s)

Let’s say we’re interested in sending a poll to contacts between the age of 15 and 18 years. To do this you first need to find the contacts meeting that age requirement.

Go to the Contacts tab and enter the following query in the search bar:

age>=15 AND age<=18

It should look like this:

In this example, 2 contacts were found fitting the age requirement. We can save these contacts as a group by clicking on Save as Group button. We can now send a message or poll to this particular group.

It is also possible to search for contacts meeting multiple criteria. Let’s assume we are interested in contacts who are female, are between 15 and 18 years old and who live in Kampala. In this case we enter the following query in the search bar:

gender=female AND (age>=15 and age<=18) AND district=Kampala

Here again we can decide to save the found contacts as a group.

Organize contacts based on “engagement”

You may remember this post where we showed how to keep track of contacts’ participation in RapidPro. We added an “engagement counter” which measures how often contacts participate in flows. We can use this counter to group contacts based on their level of participation using dynamic groups.

Obviously, we first need to define engagement. We could for example decide that contacts who have participated in more than 10 polls will be considered “super” contacts. Now we can search for contacts whose counter is higher than 10 by simply entering this query in the search bar:

engagement_counter>10

We may also want to take the “date of last participation” into account when measuring engagement. For instance, we consider a contact a “super” contact only if he/she participated in more than 10 polls AND has participated in a poll in the last month. To do this we could use this query:

last_participation_date>22-03-2016 AND engagement_counter>10

Using this query allows us too search for contacts that have participated after 22 March 2016 and whose engagement counter is bigger than 10. Note that the last participation date has been added as a contact field which keeps track of when a contact participates last in a poll. See this post for more info.

Identify contacts missing information for follow up

In an earlier post we said that there is no need for using temporary groups in registration flows to keep track of who hasn’t responded to what question. Besides using the Split by Contact field feature we can now also search empty contact fields in Contacts. To do this we can use the query missing_field=”“ (as in quotation marks).

For example, if we look for contacts whose gender is unknown we can use this query:

gender=””

All contacts that are missing gender information will be returned, which we can save as a dynamic group, for example "missing gender group".

Now we create a simple flow asking for just gender which could look like this:

This flow can be triggered by a campaign if you use the Registration Date as reference, or you can choose the option “Start a flow in the future or on a schedule” under Triggers.

In the case of campaign:

  • Go to the Campaign tab and click Create Campaign
  • You name the campaign and select the group to be involved and click Ok
  • You click Add Event in the next page after which you’ll see this screen:

  • Here you choose the option “start flow”, select which flow, in our case “ask for gender flow” and indicate when the flow should be triggered using the Registration Date as reference.
  • You can add as many events as you want: 10 days after registration, 20 days after registration, etc.

In case you choose to use Triggers:

  • Go to the Triggers tab and click on “Start a flow in the future or on a schedule”:

  • In the next screen you can select which flow to trigger, the contacts to receive the flow, the start date and time of the event and whether you want the trigger to be repeated (in our case every month):


Note that as soon as a contact provides his/her gender information he/she will be taken out of the missing gender group automatically (hence the name dynamic group). So there is no need to add an action in the flow to remove the contact from this group!

Important notes

  • Once a dynamic group is saved, any new contact that matches the applied query will be automatically placed in that group. This means that we don’t need to run the query again as the groups are updated automatically.

  • Space is not allowed in the contacts search bar. For example, the “last participation date” should be entered as last_participation_date. If we’re not sure how the field is named we can check under Manage Contact Fields:

  • When querying contacts you can use logical comparisons which evaluate to TRUE or FALSE. You may use the equals (=), not-equals (<>), greater-than (>), greater-than-or-equal (>=), less-than (<) and less-than-or-equal (<=) operators. When comparing text values, the equals (=) and not-equals (<>) operators are case-insensitive.

  • Make sure that any contact field containing a number such as age and engagement counter are defined as Numeric and date fields as Date & Time. If the format is not set right, the queries may not work! In the screenshot above we see that the “last participation date” field is defined as “Date and Time”. The “engagement counter” field on the other hand is defined as Numeric:

We hope this post has been useful. In case of questions or comments you can reach us at join@rapidpro.io, or join the RapidPro User Forum.