Are We There Yet? — Event Driven APIs in Azure Cloud

Mikael Beermann
If Technology
Published in
5 min readJan 13, 2022

Imagine that you are driving with kids. They are constantly asking “are we there yet”?

Are we there yet?

— Kids can be compared to apps talking to an API, which can be compared to you, to get updates in a very chatty manner. If you had been an Event instead you would avoid the nagging and could rather give updates underway. An Event could tell the kids at regular intervals how far it is left. In this case it would be you broadcasting updates. — Hey kids! There is now 1 hour to go, only 45 min now, 30 min left, 15 min — we are soon there! Sure, not all kids would be happy with this but in the digital world your apps would not start nagging at the APIs if they get Events.

So, events work a bit like the good old SMS notifications but are used for apps talking to one another. Events are different than APIs. APIs are typically used to request a set of data or functionality. To avoid having to call the API all the time to check if something has happened, the apps can use Events. If subscribing to Events, an app will be notified when there is a change and that can trigger actions.

Rescue is coming!

In If Insurance we are using Events to improve customer journeys. Recently we have collaborated with Viking, our roadside assistance company, so that we get Events when a car needs assistance. When Viking is rescuing a Polestar car, we will for example send the Event to our new Android Automotive based InCar app for Polestar so our customers will know that rescue is coming, and the time left until arrival. The Events can also be used by other mobility partners to have nearly real time status on incidents.

In addition, Accident Data APIs are available so that Viking and other partners can update and request more info on a case when a roadside assistance Event has happened. Viking can for example update the case with information about location, end-customer, vehicle, contact persons and subcontractors. Polestar can then get information for the related case in their system and thereby improve the service in their customer centers. The end-customers will be informed in our in-car app so that they can feel safe and in control of the situation.

Here is a snapshot of a customer experience for towing

The tech behind

When distributing events various technologies can be used. Since this solution focus on distributing business events to external parties outside of If Insurance, we find it important to use technology that is loosely coupled, platform agnostic, and follows open standards. Other important qualities are of course security and reliability. For this reason, we have chosen to implement the events as web hooks with messages following the CloudEvents specification (cloudevents.io). “Webhooks are automated messages sent from apps when something happens. They have a message — or payload — and are sent to a unique URL — essentially the app’s phone number or address” (Ref. Zapier).

Example Event message (unencrypted version)

Message payloads are encrypted and kept until the receiver has acknowledged successful delivery. The solution is implemented using cloud technology in Microsoft Azure with core component using Azure Service Bus for message handling, SQL Database for subscription management and App Service for custom application logic such as APIs for receiving messages and managing events. The APIs are of course published on our API platform which is based on Azure API management.

Our event service consists of three technical capabilities: A subscription service, an event receiver service, and an event distribution service.

The subscription service is used to assign and filter different event types to different receivers based on event metadata. This means we can have one client subscribing to roadside assistance events for Polestar, while another subscribes to roadside assistance events for Volvo. New subscribers can be added dynamically without the event source needing to be aware of how the subscriptions are configured.

The event receiver service is an internal API receiving event messages from various sources, placing them on internal queues to be picked up by the event distribution service. Event sources can be any kind of system, like insurance systems, claims systems, CRM, or external suppliers.

The event distributor service will pick up messages from the queues which has metadata information matching the subscription definition for its clients. The message will be encoded as a CloudEvents message. The data part of the message will be encoded using a shared key defined in the subscription to ensure integrity and confidentiality of the message. If the recipient of the message for some reason can’t receive the message the message will be resent at a later moment ensuring the message will be delivered at least once to each subscriber.

Our new event service is a very valuable complement to our API platform. Now we are not only able to share data with our customers and partners, but we are also able to tell them actively when data has changed.

Interesting in learning more about the Events and APIs? See our Developer Portal and the Events and Accident Data API there

Interested in becoming a partner? Please send an e-mail to api-support@if-insurance.com

Authors:

Mikael Beermann, API Architect

Elisabeth Falck, Head of Digital Business Enablers

Karolina Vikman, Online Sales Manager

--

--