Using Azure Function to Store data from Kaizala webhooks

In this post, we will go through an example of storing data from Kaizala in Azure Table Storage. If you are not familiar with Kaizala webhooks, please read this post for an introduction.

This post has been classified broadly into these sections:

  • Azure Function to handle Kaizala webhook data
  • Registering a webhook
  • Testing out

Azure Function to handle Kaizala webhook data

In case you are new to Azure Functions, you can follow this article on Microsoft documentation for an introduction. The example in this post will use a http triggered Azure Function written in C#.

There are broadly 2 areas we will need to handle in the Azure Function:

  1. Handling the validation token
  2. Handling the webhook callback data

Handling the validation token

Kaizala service validates the endpoint being used to subscribe for webhooks by issuing a GET request to the provided URL with the validation token in the query string parameter. For a successful validation, you will need to return the validation token as plain text in the response body. Below screenshot shows the code for this:

Fig 1 – Returning webhook validation token

Handling the webhook callback data

Once the webhook has been successfully registered, Kaizala service would give callback through a POST request with data in the request body. In our example, we would store the data in an Azure Cloud Table. Below screenshot has the code where the data is parsed and stored into the Azure table. Post processing the data, you will need to return a 200 OK back to Kaizala service within 60 seconds. If you fail to do this, Kaizala service will mark your webhook callback as a failure and will retry and after a few retries will disable the webhook.

Fig 2 – handling Kaizala webhook callback

Registering a webhook

Once your Azure Function is ready, you can register a webhook to your Azure Function. Get the URL of your Azure function (if you are unfamiliar of how, you can refer to this article again).

You can use Postman REST client to register the webhook. Below screenshot is an example:

Fig 3 – registering for Kaizala webhook events to Azure Function URL

On successful registration, you should get a 200 OK with the webhook id in the response.

Fig 4 – successful webhook registration response

Below is a screenshot of the Azure Table Storage with the data from Kaizala.

Fig 5 – Azure Table with data from Kaizala webhook

Closing notes

Hope this was helpful in getting started with Kaizala Webhooks leveraging Azure Functions. If you would like to get updates each time an article is published, you could subscribe to this blog.

The C# file for the code in this example has been shared here. Feel free to share your comments / questions / feedback in the comments section.

4 thoughts on “Using Azure Function to Store data from Kaizala webhooks

  1. Hi, I have multiple queries about Kaizala please share your number or any help desk where I can ask queries regarding this.
    Thanks & Regards Annie Rizvi 9026603297
    On Fri, Jul 12, 2019 at 11:26 AM Tinkering with Kaizala wrote:
    > Gladson Chellappa posted: ” In this post, we will go through an example of > storing data from Kaizala in Azure Table Storage. If you are not familiar > with Kaizala webhooks, please read this post for an introduction. This post > has been classified broadly into these sections: ” >

    Like

Leave a Reply to Gladson Chellappa Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s