How to create a Marketing Automation Event?

Marketing automation events are used to launch a scenario connected to an event. The scenario covers any available automation in CareCloud platform.

Marketing Automation Events has the following structure of resources:

Event group: groups divide event types into administrator-defined categories. An administrator can add, edit or delete event groups from the administration environment of the CareCloud platform.

Event type: It is a general definition of an event. As an administrator, you can define event types that describe the behavior and structure of following events.

Event properties: It is a list of properties defined with the connected event type. It is a good way how to extend event type possibilities.

Event: It is a resource that allows you to create an event for a specific customer. The event starts a Marketing Automation scenario. It can transfer data to the scenario. Marketing automation scenarios can use the data to make better decisions during their run.

Event property record: It contains values of property that is connected with an event.

Create an event

  1. If you want to create an event through CareCloud REST API, make sure you know what type of event you wish to create. Correctly set it up, and check if it contains all necessary properties. If you need to create a new event group, you can do it in the events section of the CareCloud administration. You can also create a new event type or property there. When everything is set up in CareCloud administration, we can go to the next step.

  2. First, you have to decide what event type you want to use to create an event. To help you decide, you might select an event type depends on the event group. List of the groups you can list with API call of resource event-groups:
GET <projectURL>/rest-api/enterprise-interface/v1.0/event-groups
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
#<user name>:<password>
Authorization: Basic Y3VzdG9tZXJfaW50ZXJmYWNlOmNlMzZjMDg2YmZjN2U3YjBkMjNjNjY3YjdhOTUxZTk=

Depends on the results, you can select a list of event types that fits your event group or use other criteria from an event-types resource documentation:

GET <projectURL>/rest-api/enterprise-interface/v1.0/event-types?event_group_id=8bdf68d3838b4e009991
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
#<user name>:<password>
Authorization: Basic Y3VzdG9tZXJfaW50ZXJmYWNlOmNlMzZjMDg2YmZjN2U3YjBkMjNjNjY3YjdhOTUxZTk=
  1. If you decided on an event type that fits your use case, you could check if you need to use any of the available event properties:
GET <projectURL>/rest-api/enterprise-interface/v1.0/event-properties
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
#<user name>:<password>
Authorization: Basic Y3VzdG9tZXJfaW50ZXJmYWNlOmNlMzZjMDg2YmZjN2U3YjBkMjNjNjY3YjdhOTUxZTk=
  1. Now is the time to create an event for a specific customer. Call the POST method events with parameters from the documentation:
POST <projectURL>/rest-api/enterprise-interface/v1.0/events
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
#<user name>:<password>
Authorization: Basic Y3VzdG9tZXJfaW50ZXJmYWNlOmNlMzZjMDg2YmZjN2U3YjBkMjNjNjY3YjdhOTUxZTk=

{
  "event": {
    "event_type_id": "8bed991c68a4",
    "customer_id": "85bc5819e09dab9",
    "external_id": "OUIOFJDSNBALIR",
    "data": "{\"test\":10,\"test2\":20}",
    "created_at": "2020-06-20 16:59:49",
    "secondary_external_id": "test1-6"
  },
    "property_records": [
      {
        "property_id": "bill_total_price",
        "property_value": 7.5
      },
      {
        "property_id": "bill_payment_date",
        "property_value": "2021-01-29"
      }
    ]
}
  1. As you can see, the creation of events also contains values of properties. You set property records in events resource because we need to have all data available for the MA scenario in one API call to start immediately after.
    If you want to see a list of events, call the GET method with query params from the documentation:
GET <projectURL>/rest-api/enterprise-interface/v1.0/events
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
#<user name>:<password>
Authorization: Basic Y3VzdG9tZXJfaW50ZXJmYWNlOmNlMzZjMDg2YmZjN2U3YjBkMjNjNjY3YjdhOTUxZTk=
  1. If you need to see property values of the event, please call subresource of events - property-records:
GET <projectURL>/rest-api/enterprise-interface/v1.0/events/85bc5819e09dab9/property-records
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
#<user name>:<password>
Authorization: Basic Y3VzdG9tZXJfaW50ZXJmYWNlOmNlMzZjMDg2YmZjN2U3YjBkMjNjNjY3YjdhOTUxZTk=