Skip to content

Application integration for custom message tracking

What is application integration?

Application Integration is an Integration-Platform-as-a-Service (iPaaS) solution offered by Google Cloud. It encompasses a broad range of essential integration tools designed to connect multiple applications seamlessly. This service is fully managed by Google, operates in a serverless manner, and automatically scales to meet your needs. Together with its intuitive drag-and-drop user interface, it becomes a robust tool for effortlessly building, overseeing and expanding integrations on Google’s highly scalable infrastructure.

Use case: application integration for custom message tracking.

In the following use case, the objective is to customise tracking of messages sent to a certain Pub/Sub topic. You accomplish this by creating an integration that listens to this Pub/Sub topic and behaves depending on the received message. To increase the ease of use, you will facilitate access of tracking data through a tool like Google Sheets. With the aid of application integration, you can establish this behaviour in a scalable way, while keeping the implementation relatively simple. The integration used for this use case is shown in the figure below.

The workflow starts with a Pub/Sub Trigger that will initiate the processing upon receiving a message to the designated topic. The main control flow then exists of a JavaScript task which extracts and processes the data from the message. Followed by a DataMapping task that generates a request from the data to send to the Google Sheets API. Finally, you use the Sheets – Append task to send the request to Google Sheets. 

Setting up authentication: in order for the integration to possess the correct access privileges, you need to set up an authentication profile using a service account in the authentication profile tab. To give it access to the Google Sheets API you need to add “https://www.googleapis.com/auth/spreadsheets” to the scope of the profile. The service account does not need any other roles/privileges whatsoever. The settings of the authentication profile can be seen in the figure below. To give the profile access to your Google Sheet, you must grant ‘Editor’ rights to the service account’s email address on your sheet. This authentication profile will also be referred to in the Sheets – Append task.

Processing data: For this step, you need a Pub/Sub topic to ingest the messages into the system. This topic is to be referred to in your application integration Pub/Sub trigger. As a result, your application integration workflow is triggered each time a message is sent to the topic. The message content can also be used in the context of the integration. To facilitate the extraction and processing of data from the incoming messages, you can employ a JavaScript task. This task executes a singular function which takes the complete context of the workflow as input. Within this function, the fields of the Pub/Sub message can be read and subjected to processing.

Sending data to Google Sheets: for the sheets API to work properly, the row data needs to be accompanied by some static metadata. To attach this metadata,  you can create a local variable inside the integration context with the static data as the default value. You can then use the Data Mapping task to combine the processed Pub/Sub message with the local variable using the “MERGE” function. The task schema can be seen in the figure below. The combined data packet can then be sent as a request to the Google Sheets API using the Sheets Append task. For the Sheets Append task, the authentication profile created in the last step needs to be referred to as this account has access to your sheet. 

Adding more custom behaviour: sending mails on certain Pub/Sub messages

Suppose for some received messages you want to respond by sending mails to inform a recipient. This can be a static recipient, for instance, someone who manages the message tracking. This can also be dynamically chosen depending on the received message. To add this behaviour to your integration you can just create a fork after the JavaScript task with the extra edge being conditioned on whether or not a recipient should be notified via email. Furthermore, after the newly added edge, a Send Email task must be installed. This task is defined by a receiving e-mail address, subject and body. All of these fields can be dynamically assigned depending on the received message. The extended integration is shown in the figure below. 

Why you should use application integration

Application Integration sets itself apart by having a user-friendly interface and capabilities to quickly create an integration that connects different applications. Next to this you can also easily modify and extend the behaviour of the integration. Setting up custom integrations where different applications communicate with each other can often become very complex for even the simplest use cases. With the usage of Google Cloud’s application integration, these implementations become much more simple, which can help development teams become more efficient and agile.

Other use cases that can serve as a source of inspiration.