Recipe - Kentaa / iRaiser integration

Kentaa / iRaiser is a digital fundraising platform for teams and individuals. This guide shows how to replicate Team, Actor and Donation records on Salesforce using Flow External Services. Teams will be created using a platform event triggered flow. The flow runs when the webhook receives "Team Created" events for any team member.

Contents
Salesforce Platform Event Setup
Flow A - Receive the webhook
Flow B - Process the events
Testing the integration

These concepts are used in the scenario:

Salesforce Platform Event Setup

Kentaa provisions each user a custom environment with sample fundraising data configured. They provide an API key to support callbacks. For this demo, choose the following configuration: Site > Team Fund Raiser

Kentaa Donations
We link each Donation to a Salesforce Task.

Kentaa Actors
Each fundraising Actor will be represented as a Salesforce Contact. The tasks are related by the Who ID.

Kentaa Teams
Several actors form a Team which is represented as a Salesforce Account. The tasks are related by the What ID.

Salesforce External IDs

Create the necessary Salesforce fields to implement the model.

Account object - add an External ID representing the Kentaa Team.

Contact object - add an External ID representing the Kentaa Actor.

Task object - add an External ID representing the Kentaa Donation.

Kentaa Team Creation

Simultaneous team events - for every team member - are sent to Salesforce when the Save button is clicked on the Kentaa platform. This causes a race condition where multiple webhooks are triggered at the same time, all assuming the absence of the team or account record.

To ensure the safe creation of records, we use a Platform Event to convert the parallel stream of Kentaa's events into one collection that is processed sequentially in a later context. Then we use a flow to handle each Kentaa notification from the event queue and process them serially.

// Kentaa Event Message Structure
{ "object_type": "action", "object_id": 42, "event_type": "counters.update", "application": "Kentaa", "site_id": 12 }

Start by creating a platform event to process the Kentaa notifications. The platform event will have a single Body text area field capped at 131,072 bytes. This size always accommodates the full Kentaa notification payload.

Kentaa Named Credential

To retrieve the full event detail, the recipient of the webhook must call back into Kentaa using a combination of the object_type and object_id as the retrieval key. Retrieving this data is achieved below using flow.

Create a Named Credential to hold your Kentaa API key. At runtime, the named credential resolves the URL to the configured Kentaa physical endpoint. It securely manages the auth for an external service callout on behalf of the user performing the callout.

Click Save, then return to the Kentaa Platform Event flow

Salesforce External Services

Create three external services to support the Team, Actor and Donation callouts.

Navigate to Setup > External Services

For each service, repeat the following steps.

1. Select an API source: From API Specification.

2. Complete the registration details for each service.

Team

Actor

Donation

3. Click Save & Next

4. Check the available GET operation.

5. Click Finish.

Three external services from Kentaa are now available for use in flow.

Flow A - Receive the webhook

Notifications sent from Kentaa will trigger the webhook flow. This flow receives each incoming Kentaa webhook, extracts the JSON payload, and publishes it in the body of a Platform Event.

1. Convert the webhook payload to a platform event

# Streamscript
$Webhook.response  = '200 - OK'
$Kentaa_Webhook__e = New-Kentaa_Webhook__e
$Kentaa_Webhook__e.Body__c = $Webhook.request
return $Kentaa_Webhook__e 

The script returns a custom Platform Event that holds the event notification JSON.

2. Publish the platform event

3. Save and activate the flow

This flow setting ensures the Site Guest User can insert records.

Flow B - process the events

The Platform Event converts the parallel event notifications to a serial collection, providing a view across related inbound events in the same flow execution. Each notification in the batch is categorised by type: either donations (Tasks), fundraising actors (Contacts), and teams (Accounts).

Duplicate notifications are filtered out using the Decision step. The filtered events are directed to the 'skipped' path while the remaining events move forward for processing. These paths conclude with a Salesforce upsert.

Start by creating a new Platform Event Triggered Flow in Setup > Flows > New. This flow will subscribe to the platform events published by the earlier webhook flow. Select the platform event type Kentaa Webhook. Save the flow.

1. Add the Filter step

Add a Streamscript step as the first step in the flow

Paste this logic which filters out duplicate events.

# Streamscript Bulk
$ids = []
$types = []
$uniqueKeys = []
$items = {!$Record}
foreach ($item in $items)
{
    # read the webhook body
    $o = Json-Decode $item.Data__c
    
    # filter
    $id = $o.object_id
    $type = `$o.object_type|$o.event_type`
    $key = `$type|$id` # eg: team|sign_ups.create|12345
    
    # mark duplicates as null
    if ($uniqueKeys.contains($key))
    {
        $id = null
        $type = null
    }

    # collect items
    $uniqueKeys.add($key)
    $types.add($type)
    $ids.add($id)
}

return -num $ids -text $types

2. Add the Decision for Event Type

The Decision step will route events from the filter to Team / Actor / Donation paths. Other events go to the Skip path.

Object Type Event Type Value Outcome
team sign_ups.create team|sign_ups.create Team
actor sign_ups.create action|sign_ups.create Actor
donation sign_ups.create donation|sign_ups.create Donation
donation donations.update donation|donations.create Skip
null null null Skip

Add an Outcome: Team

Add an Outcome: Actor

Add an Outcome: Donation

Default Outcome:

3. Upsert the Team

Under the Team path, select the Team External Service to perform the HTTP callout.

Add a Get Records step (Account) to check if the team already exists in Salesforce.

Add an Assignment step to set the Kentaa Team ID and Kentaa Team Name using the response from the callout.

Add a Decision step to check for an empty ID on the retrieved account.

Add an Update Records step under the Account Exists path.

Add a Create Records step under the Not Exists path.

4. Upsert the Actor

Under the Actor path, select the Actor External Service to perform the HTTP callout.

Add a Get Records step (Account) to locate the related team.

Then add a Get Records step (Contact) to check if the actor already exists in Salesforce.

Add an Assignment step to populate the Contact fields.

Add a Decision step to check for an empty ID on the retrieved contact.

Add an Update Records step under the Contact Exists path.

Add a Create Records step under the Not Exists path.

5. Upsert the Donation

This inserts a Task representing the Kentaa Donation. Before inserting, we resolve the Team ID to its corresponding Salesforce Account and the Actor ID to its corresponding Salesforce Contact. These will be mapped using the WhoId and WhatId fields on the task record.

Under the Donation path, select the Donation External Service to perform the HTTP callout.

Add a Get Records step (Account) to locate the related team.

Add a Get Records step (Contact) to locate the related actor.

Add a Create Records step (Task).

The completed flow now looks like this:

Testing the integration

Navigate to your participation page provisioned by the Kentaa team and choose: Generally for Test.

Select Team, then click Continue. Add your team leader, an additional team member, then name the team.

Finally, make a donation as the team leader via the simulated payment gateway.

When you click Submit, Kentaa sends a number of webhooks to Salesforce. These create:

You can add more fields as needed. Have fun!