Back

GoodBarber + Zapier: automatically add a user to a group

on 

It's official: GoodBarber integrations with Zapier have reached a milestone. More and more of you are building workflows between your GoodBarber app and other Zapier-compatible services. GoodBarber integrations with Zapier are no longer marked "beta", and that's something to celebrate!

As a reminder, we have developed 2 integrations with Zapier:
- GoodBarber: this integration offers actions and triggers for content apps
- GoodBarber eCommerce : this integration offers actions and triggers for eCommerce apps.

In this article, I'll give an example of how to use the integration for content apps. I refer you to this article by Marie, which explains how Zapier works in general, and this one , which contains an example for eCommerce apps.

Let's take the case of an app that uses the authentication and user group extensions. I've created 2 groups in this app. My aim is to automatically assign each new user who registers to one of the 2 groups.
In the user profile creation process, I've added a multiple-choice question. Depending on the user's choice, thanks to my Zapier automation, I'll assign the user to group A or group B.

Before we start, we need to add the Zapier extension to the app and create an API key to connect the app to Zapier. This prerequisite is well explained in this online help .
I start my zap with the "New User in GoodBarber" trigger. Each time a new user registers in my app, the info associated with their registration is sent to Zapier and the automation begins.

Next, I add a "Find a User in GoodBarber" search action. This allows me to find out the group chosen by the user when registering. The search criterion expected by this action is the user's email. The user's email is given to me in the previous step. I just need to use it in this step.
In terms of search results, the information I'm interested in is in custom_fields, and more precisely, the name/value pair where:
  • name = the name I've given to the custom field I've added to the app's registration process, in this case, "Preferred group".
  • value = the choice made by the user at the time of registration among the 2 choices proposed. The value 0 corresponds to the first answer (choice 1), and the value 1 to the second answer (choice 2).
Clearly, if value = 0, then I move the user to group A, and if value = 1, I move the user to group B.

To do this, I now add an action that will divide the path of my zap into 2. This is the "Paths" action. It's a default action in Zapier.

The zap continues with Path A if value = 0
The zap continues on Path B if value = 1
In Path A, I fill in the rule that allows this path to be taken if true:
"Only continue if Custom Field Value exactly matches 0".
Custom Field Value is the value of the "Preferred Group" custom field obtained in step 2 of the zap.
I then add an "Add user to Group in GoodBarber" action. To set this action, I enter:
  • Group A ID. There are several ways of obtaining this ID. You can use the "Find a group" action in Zapier, or the "List all user groups" method in GoodBarber's public AP I. I followed the second option, using Postman to retrieve the results returned by the API. I'll explain how to do this in a future article.
  • User ID. This information is available in the results of step 2 of my zap. I'll simply reuse it here.
To configure Path B, I perform the same operations as for Path A :
  • by changing the path-following rule. We need the value of the custom field to be equal to 1
  • with Group ID B instead of Group ID A.
That's it, my zap is complete.
Now, when a user registers in my app, they're automatically moved to the right user group.