Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

Using an Application Automation to serve as an Advanced Analytics Connector

cancel
Showing results for 
Search instead for 
Did you mean: 
Dalton_Ruer
Support
Support

Using an Application Automation to serve as an Advanced Analytics Connector

Last Update:

Apr 6, 2024 3:11:57 PM

Updated By:

Dalton_Ruer

Created date:

Apr 6, 2024 3:11:57 PM

My Catch 22

So here was the situation I was facing, my boss was screaming at me to do something that didn't exist so I ... alright truth be told he was never screaming at me and he was fine with the initial work around I came up with. I was the one screaming to try and connect to the Google Gemini Pro #LLM in the same Server Side Extension manner I had been for other Large Language Models. I wanted to be able to ask a question and get a response, but also have the response be responsive if I filtered selections in the data. 

The problem is that the API for Google Gemini Pro expects a nested block of JSON, and the generic Advanced Analytics Connector only sends a basic JSON block with field/value pairs. But my hero, Daniel Pilla, helped me realize that a Qlik Application Automation will accept the basic JSON field/value pair block and that I could then infuse the question and data into the URL call as needed for the Google Gemini Pro API. 

Feel free to watch the video and skip all of the yapping I do after it. Or if you think it might be helpful and actually want to try, feel free to read the step by step instructions to give it a try on your end. 

Video

 

Yapping with Step by Step Instruction

To test let’s create a brand new Qlik Application Automation

Dalton_Ruer_1-1712429182941.png

 

Be sure to set the Start block to Triggered and keep a copy of the information that it will display for you as to how to call the automation you will need that when creating the Advanced Analytics Connector inside of Qlik Sense momentarily.

Dalton_Ruer_2-1712429182947.png

Then add an Output block that will simply output “Yeah I did something”

Dalton_Ruer_3-1712429182954.png

Create a new Qlik Sense application and go to the Load Script.

Before adding our Advanced Analytics connector we need to add some sample data to our load script to test with:

Data:

Load * Inline [

Question#, Prompt

Question 1, "Human: What can you tell me about the Qlik Associative Model and why customers love it so much? Assistant:"

];

 

Choose Create new connection and then choose Advanced Analytics

Dalton_Ruer_4-1712429182955.png

 

 

Simply copy the URL from the Automation you just created, and then create a HTTP Headers entry for X-Execution-Token as shown and the token provided.

Dalton_Ruer_5-1712429182958.png

In the Response Table section simply input any table name value you wish for the Name of Returned Table and uncheck the box that says Load all available fields, and set the Table Field (JMESPath) to response and response.

Dalton_Ruer_6-1712429182960.png

You will see why based on the data in a second but for now just enter Question# as the Association Field and be sure the Send Association Field box is not checked:

Dalton_Ruer_7-1712429182961.png

Save your newly created Advanced Analytics connector.

Now choose the Select Data icon for your Advanced Analytics test connection

Dalton_Ruer_8-1712429182966.png

After you type in the name of our sample data table “Data” the connector will then show you what information will be returned. Notice in my image it’s the AnyNameYouWant table because that is literally what I input, your screen will contain the name you used.

Dalton_Ruer_9-1712429182969.png

Run the load script and you will see that you sent 1 row and you got 1 row back:

Dalton_Ruer_10-1712429182971.png

Keep in mind that we didn’t do anything special in our Qlik Application Automation yet, we are simply using this as a test to understand HOW the Advanced Analytics Connector works. So let’s go over to the Qlik Application Automation you created and see what we learned.

Click on your Output block and delete the “Yeah I did something” text that was being output previously:

Dalton_Ruer_11-1712429182973.png

Now from the dropdown for Data to output choose the right arrow icon for Output from start because we want to see what it actually contains:

Dalton_Ruer_12-1712429182979.png

Not surprisingly it shows us that it received a simple record. Now click the Toggle view mode icon so that you can see what I mentioned at the onset. It is the very simple JSON block with a simple field/value pair that is passed in:

Dalton_Ruer_22-1712429675958.png

With that knowledge untoggled the View mode so we see the array instead and type
“You asked for: ” then click the Prompt field and choose Select first item from list. (While you saw it knows we only passed 1 entry, it assumes the body can be an array. So we need to select the first one, which is all we would ever pass it.)

Dalton_Ruer_14-1712429182982.png

Dalton_Ruer_15-1712429182984.png

Instead of calling the automation from the load script again, lets build a simple Analytics sheet instead.

Simply add a Text & Image chart to your new sheet.

Dalton_Ruer_16-1712429182984.png

 

Now add a measure

Dalton_Ruer_17-1712429182985.png

And use the following string as your expression. The connectionname you use is the one you created and you can copy it right from the load script if needed to ensure you have spelling and spacing correct:

Dalton_Ruer_18-1712429182987.png

Your measure expression should be: 

endpoints.ScriptEvalStr('{"RequestType":"endpoint", "endpoint":{"connectionname":"Advanced_Analytics"}}', 'Tell me a dad joke' as Prompt, 'Qlik Dork' as UserName)

The measure we added is evaluated and our Text & Image Chart now contains the response from our Automation:

Dalton_Ruer_19-1712429182988.png

Now let’s go back to the Automation and take another look at it. We know we were just forcing the Output value, it’s the Start block that we care about. Notice that now the Start block had a plain JSON body with both fields.

Dalton_Ruer_20-1712429182990.png

Now let’s add a Table object to our screen. Add the Question# and the Prompt as dimensions. Then add a measure with the following expression:

endpoints.ScriptEvalStr('{"RequestType":"endpoint", "endpoint":{"connectionname":"Advanced_Analytics"}}', Prompt)

Yeah … we can call our Automation as an SSE style Advanced Analytics connector and we know that we can pass fields from our actual data, or made up values as needed.

Dalton_Ruer_21-1712429182993.png

Summary

We know there is nothing super exciting about getting a return value that repeats your question. But this post is just the foundation for you to build upon, which is exactly what I did and what I refer to in my video. Who knows what you may try and utilize the Advanced Analytics Connector for and when you encounter a red screen error or something you will know just what the issue may be.

On my end, one Dan helped me know I could call my Application Automation from an Advanced Analytics Connector, the rest of my problem was resolved quickly. All I simply had to do was add the simple basic URL block to my automation and call the Google Gemini Pro API. 

Dalton_Ruer_23-1712430309229.png

In a similar fashion to what it expects, their API returns a nested block. I was able to pull that value out and return it as the result. 

Dalton_Ruer_24-1712430439008.png

 

 

 

 

 

 

Contributors
Version history
Last update:
4 weeks ago
Updated by: