Adobe Campaign Standard and Web Push Notifications

Rob In der Maur
Aug 13 · 6 min read

We have published before how Adobe I/O can polish some of the rough edges of Adobe Experience Cloud solutions. This article explains in more detail a specific example using Adobe I/O Runtime.

External API

Adobe Campaign Standard (ACS) has overcome a limitation in its functionality with the introduction of the External API activity. With that activity (currently in public beta) it is now entirely possible to invoke an external service through its exposed API from within a campaign workflow. More details on how this works can be found in a tutorial and in more detailed documentation.

This functionality opens up a myriad of integration possibilities for ACS. There is one caveat though: In order for ACS to handle both input and output of that External API activity, in line with its underlying data model, some conventions are required regarding the JSON payloads for input and output. But we all know, none of the APIs of the service you want to integrate with adhere to these conventions by default. That is where Adobe I/O Runtime comes to the rescue. More on that later.

Web push notifications

Let's first imagine, we want to facilitate web push notifications from ACS. Out of the box, ACS supports email, direct mail, SMS, mobile push notification (iOS, Android), and in-app messaging as channels. To add web push notification functionality to ACS, we will use Firebase Cloud Messaging, a Google service to deliver and receive messages and notifications on web browsers.

Registering for web push notifications

Our focus in this article will be mainly on sending web push notifications; however, to send web push notifications to browsers, a browser needs to register for these. Google documents how to add Firebase to a web client app and receive registration tokens. It is our responsibility to store these in ACS and link them to a profile. This means:

  • We have to setup a custom resource in ACS for keeping track of web push notification registrations and their statuses;
  • We must enable our web app to lookup ACS profile details (based on an email provided) and then store the registration token associated with the profile in the custom resource.
Entry for web push notification registration in the Web Push Subscriptions custom resource.

We leave it as an exercise for the reader to setup this registration process. However, do note that you will need ACS API calls to lookup the profile and to store the registration in the custom resource. And you may very well want to use Adobe I/O Runtime to wrap these calls and their required service account integration in easy accessible REST API's.

Sending web push notifications

As mentioned before, our focus will be on sending web push notifications using the new External API feature of ACS. Google's FCM offers various interfaces for sending web push notifications from an FCM server (ACS is actually acting as the FCM server here). We will use the recommended Firebase Admin SDK, which has support for NodeJS. We also anticipate we might want to send more than one web push notification as part of an External API activity, based on a previous selection of subscribers in the workflow. So our designated API call to use is admin.messaging().sendMulticast(message) .

That API call uses message as input, a JSON payload with the following syntax:

{
"message": {
"tokens" : [{device_token}, {device_token}, ...],
"notification" : {
"body" : "This is a Firebase Cloud Messaging Message!",
"title" : "FCM Message",
}
}
}

and response as the response, which conforms to the following JSON syntax:

{
"responses": [
{"success”:true,"messageId":messageId},
{“success”:true,”messageId”:messageId},
...
],
"successCount":successCount,
"failureCount":failureCount
}

The External API activity is quite strict in the format it accepts for both inbound and outbound mapping. For inbound, the format is dependent on the inbound columns you want to use from a previous step in the workflow as well as any additional custom fields you want to use in defining the web push notification.

External API Inbound Mapping configuration.

In our example, we use the registered device tokens to identify to whom we are going to send web push notifications and we define title and body the same for each notification. This results in the following JSON payload:

{
"params": {
"count": count,
"body": body,
"title": title
},
"data": [
{
"
deviceToken": deviceToken
},
{
"deviceToken": deviceToken
}
...
]
}

For outbound mapping, we need to take into account what data we want to update in our customer resource and how to identify updates (i.e. device token).

External API Outbound Mapping configuration.
External API Column Definition

Again, the response we ultimately get back from the API call has to conform to the JSON structure expected by the External API activity for outbound mapping.

{
"data": [
{
"deviceToken": deviceToken,
"messageId": messageId,
"success": true|false
},
{
"deviceToken": deviceToken,
"messageId": messageId,
"success": true|false
},
...
]
}

Adobe I/O Runtime to the rescue

Now we have identified what is required for sending web push notifications through ACS, we have a couple of loose ends we need to solve:

  • How do we handle the authentication that allows us to send web push notifications?
  • How do we overcome the difference between input/output expected by the Firebase API call and the input/output prescribed by the ACS External API activity for its mapping?

As mentioned earlier, this is where Adobe I/O Runtime comes to the rescue. With a simple Adobe I/O Runtime action, developed using NodeJS, we can:

  • take care of the authentication,
  • transform the External API activity inbound mapping to the input the FCM API call expects and
  • transform the FCM API call's response to the External API activity outbound mapping.

The source code for this Adobe I/O Runtime action is available on GitHub, together with instructions on how to install, deploy, configure, and use it. The code itself is simple, yet powerful, solely focusing on the above responsibilities but obviously ready to be enhanced (e.g. personalised web push notifications, more versatile notifications, etc.).

Once the code is deployed and configured, you have your own clever Adobe I/O Runtime API that you can specify as part of the Execution configuration of your External API activity.

External API Execution configuration.

With the External API and Adobe I/O Runtime we can now build a campaign workflow that selects profiles that have registered for web push notifications, send them a notification, and update our web push notification tracking accordingly, similar to the workflow below:

Adobe Campaign Standard campaign workflow to send web push notifications.

A final remark

Let's make a final remark, actually sort of a disclaimer. The intent of this article has been to show the integration capabilities opened up by the combination of the External API activity and Adobe I/O Runtime.
It has not been to demonstrate how to add a new channel to ACS. There is still a lot of additional capabilities missing to consider this example integration a full fledged ACS delivery channel. But foremost, creating a new delivery channel is also not what the External API activity in general is meant to facilitate, due to its limitations.

Conclusion

Adobe I/O Runtime can substantially increase the functionality of Adobe Campaign Standard workflows with the External API activity. We can make that External API activity work almost any way we want thanks to the flexibility of Adobe I/O Runtime.

Adobe Tech Blog

News, updates, and thoughts related to Adobe, developers, and technology.

Rob In der Maur

Written by

Working @ Adobe, enjoying life. Definitely not mutually exclusive.

Adobe Tech Blog

News, updates, and thoughts related to Adobe, developers, and technology.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade