Eventbrite to CDS Integration - Part 4 (Event Flow)

In this fourth post we will update the original flow that we created for when a new event is created in Eventbrite. The flow should have a couple of steps as the baseline. The steps include When a HTTP request is received, and the Initialize Variable action.

When the Webhook calls the flow, there are certain values that are being passed. One of those values is the action that is being performed (under the config section of the json file).

In our Initialize Variable action, we previously specified the following Action: Action Type, of type String. We did not specify the Value, which we left for now. The value should be as follows (based on the json schema that we provided):


Eventbrite Integration - Event Flow Initialize Variable Action Type

The next action will allow us to get the Event Number. We need this number to verify if the Event already exists in our CDS environment and we need to update it, or if we need to create a new event in our environment. This action will also be an Initialize Variable action as shown in the image below.

Eventbrite Integration - Event Flow Initialize Variable Event Number

The value of the Initialize Variable action is: last(take(split(triggerBody()?['api_url'],'/'),6)), which will return the event number from the api url.

We now need to verify if the action type corresponds to an event. We will add a condition action that will compare the action type to “event”. If the result will be valid, we will retrieve additional data from the event by calling the custom connector, or terminate the flow if the result is not valid.

Eventbrite Integration - Event Flow Condition Action Type = Event?
If the results from the condition action is No (not valid), we terminate the flow with a status of cancelled. I the results from the condition action is Yes (valid) we will perform a few additional steps which include:

  • Retrieve Event (from Custom Connector)
  • List Events (to check if I already have an event)
  • Condition to check if I have existing Events
    • If yes, Update event
    • If no, Create new event

Eventbrite Integration - Event Flow Condition Results

The Retrieve Event action, calls the custom connector and expects a single string variable containing the event id that we want to retrieve. The Event Number has been provided for the Initialize Variable action prior to the conditions.

Eventbrite Integration - Event Flow Custom Connector Retrieve Event

You will need to make sure that you specify the Api Key to your custom connector before the follow can execute. When you Edit the connection and the Api key prompt shows up, make sure that you enter Bearer before the Api key. For example, if your Private Token (API key) in Eventbrite is ICE1MDAC3YBZKOAIDS1W then you will have to enter Bearer ICE1MDAC3YBZKOAIDS1W in the popup window.

Eventbrite Integration - Custom Connector Authentication Key

Next we retrieve any events from CDS that already have this Event Number. We can retrieve this done by using a Filter Query or a Fetch Xml Query in the List Records action of the Common Data Service (Current Environment) connector. For our purpose we used the Filter Query, but the Fetch Xml can be used as well.

Eventbrite Integration - Event Flow List Events

We can now add a condition to check if an event exists with that number by checking the length of the results from the List Events action: length(body('List_Events')?['value'])

Eventbrite Integration - List Events Condition

The results of the condition are simple. If it does exist, we call an Apply to each that will update all the records (there should be only one), and if it does not exist we create a new event record. You will notice in the screenshots below we use the results from the Retrieve Event from the custom connector and use those parameters in our Create and Update actions.

Eventbrite Integration - List Event Condition Results (Yes/No)