Sometimes the options available in the Sense Cloud scheduler are not sufficient to build the application reload chain that is required. Perhaps loads need to happen in response to external events, or be started by someone that you don’t want to give that level of access to in Cloud. A simple Qlik automation can solve this by kicking off the reload from a webhook. This post shows you how.
What are Webhooks?
Webhooks are a simple way of getting disparate systems to talk to each other. They allow the triggering of events simply by calling a URL, this could be from a browser bookmark, a link on a page or in code. I’ve previously blogged on a use of webhooks in the article Using IFTTT and WebHooks To Send Data From Qlik Sense.
In a Sense context the webhooks can be called by creating a Link in the Sense Hub, adding a link to a Button object, a value in a table set to HTML or by calling the webhook from within the load script (using a REST connector to make the call). Triggering from the load script allows the building of reload chains that are not dependant on the Sense scheduler, and for reloads that are data dependant – for instance calling a reload of another app only when certain data are found in the current app.

What Are Qlik Automations?
You may have noticed the button Automations on the left hand side of the Sense Hub. Under here is a real treasure trove of components that can be used to build complex event driven automations. A lot of the components integrate with your Sense environment, for instance sending Qlik reports to recipients based on loading addresses from an data source. There are also a number of components to integrate with services outside of the Qlik environment, such as Teams, Slack, Hubspot etc. etc.. The automations that you create here don’t necessarily even need to have a Qlik component involved, for instance you could have an automation that posts to Teams when a new row appears in a Google Sheet. There is a whole host of no-code, drag and drop, opportunities to explore here. For now we are going to create a simple webhook that receives the GUID of an application and reloads it.
Creating the Automation
From the left hand menu in the Sense Hub select Automations, and then click the Create New Automation button at the top right. If you don’t see these options then you don’t have the permissions to create Automations, and will need to get this granted to you by an administrator via the Sense Console.
You will now see a large number of pre-canned templates for automations (which you can explore later), for now though select Create Without Template at the bottom left of the dialog. You will now be prompted to give your new webhook a name and description, and choose where to store it:

You will be presented with an almost blank workspace, just with a single Start block in the middle. The properties for this block are on the right hand side. Change the Run Mode to Triggered. You will then see the code, including the execution key you will need to trigger the automation.

Next you need to add an Input block, to receive the GUID for the app you wish to reload. On the left hand side search for Inputs then drag the inputs component immediately under your Start block, you will see a green dot when it is in place and when you drop the new block should be connected by a straight line. Set the Label to app and the Input Type to Data.

At this point you need to inject a value into the app parameter, so that it can be used in the next step. First you will need to save the automation using the Save button at the top of the page. Then, from the POST example on the Start block (pictured above), copy the text from https:// through to the end of the execution token (in this case guV1). Paste this whole string into a new browser tab and make the following edits: add a ? after the word execute, delete from there up to X-, replace the colon and space with an equals symbol, then add to the end of the URL &app=x. So, given the example pictured above the complete URL would be (with the * characters replaced with your details):
https://****.**.qlikcloud.com/api/v1/automations/****-****-****-****/actions/execute?X-Execution-Token=***********&app=x
Click enter to call the URL, and you will simply see [] returned in your browser. Leave that browser tab open (you will need it shortly) and return to the Automation editor.
The next bock you require is the one that actually triggers the reload. On the left hand side click on Qlik Cloud Services and search for the Do Reload component. Drag this under the Inputs component. In the properties panel drop down under the App Id field and select Inputs (this relates to the previous node) then click History and select app: x from under Inputs (this is what you passed in during the previous step). Set the Run Mode to be Start reload and continue.

Finally you need to add an Output node, so search for this on the left hand panel and then drop it after the Do Reload node. In the Data to output properties, you should see that it has the Do Reload node as the output it will send as a result. If it does not, drop down here and select Output from Do Reload and then Do Reload.
That is the Automation completed, so click save up the top of the sheet to finish.
Now you will need the GUID of an application that you want to reload. The GUID can be found in the URL when you have an application open, you will find it between app/ and /overview or /state. It will look a bit like this: 0e316df1-fd5c-4cd0-bac1-2f66a03b4c3d. Copy this to your clipboard and return to the tab where you called the webhook previously. Replace the x at the end of the URL with the GUID and return again. This time you should get some JSON returned, confirming that the reload has started. Check the details of the app that you have chosen to reload in the Hub and you should be able to see that a reload has started.
Calling The Webhook
As you have seen, you can call your new webhook simply by pasting it into the URL of a browser. It can also be bookmarked, for ease of use. You can create different bookmarks for each of the different apps you want to allow people to reload and most browsers will allow you to export bookmarks to give to someone else to import into their browser. The Sense hub now allows you to add links to the hub, so you can create links in there. Buttons in Sense allow you to call URLs, so that is somewhere else you can call the link.
The resultant webpage is a bit messy, so you might want to have a page that calls the webhook with javascript and parses the output and gives a friendlier results page, or perhaps just triggers a back action to take the user back to where they came from.
To call from a Qlik load script you will need a REST connector created which has the webhook as the URL. If you have a lot of apps you wish to reload in this way you will want to have a placeholder URL in your rest connection and then replace the URL in the script using a WITH CONNECTION statement. I describe how to do this in the blog post I referenced at the top of this article: Using IFTTT and WebHooks To Send Data From Qlik Sense.
Hopefully that gives you what you need to be kicking off reloads from various different events and in various different ways. If you have used similar techniques please feel free to share them in the comments below.





Leave A Comment