Hello bot friends,

    This is the first of some posts I will publish here to share with you the process of creating an Analytics Chatbot with Qlik Sense. The first and most important step is to be able to connect to Qlik Sense, so this first article will serve to check you have connection to the server and the basic configuration is setup. In next post I will show you how to create a Telegram Bot and use it to run commands from Telegram to show KPIs from the Qlik Sense application. Later I will show you how to integrate Natural Language Processing, and then advanced functionallities to give more use cases to your Telegram Bot.

 

 

    The first step when creating this type of applications is to be able to connect to the Qlik Sense server. But before this step, we need to configure the Qlik Sense server to be accessed by the Chatbot program. So let's start with the server configuration.

 

    In my case this is the architecture I am using is like this:

Single Architecture.png

    In the Bot Server is where I have installed Visual Studio to develop my Chatbot, and I connect to a Qlik Sense server to obtain the analytics that later will be sent with Telegram to the users.

 

Note.- If you do not have Visual Studio, you can start with the Community version here: https://www.visualstudio.com/vs/community/

 

    I will access the Qlik Sense server using Header Authentication because it is easier and quicker to implement. I am using a virtual proxy to separate the access for Bot users from other accesses, and to allow an easier governance in the Management Console. Anyway, for a production environment, you also have many other options for Qlik Sense authentication, like Ticketing, SAML, Oauth, etc. You can have more information about the different options here: Authentication solutions ‒ Qlik Sense

 

    This means there are some steps to complete in the Qlik Sense server before proceed to check the connection:

 

  1. Create a Stream called Bots. Give Read Access to users in directory TELEGRAM (maybe this directory is not in the proposed list yet, but you can write it down).
  2. Publish the Consumer Goods Sales Bot application to this Stream. You have it attached to this post. This is like the original, but with chart titles for all objects, to ease the search for charts.
  3. Create a Virtual Proxy, for Header Authentication, with the following parameters
    • Description: Telegram

    • Prefix: telegram

    • Timeout: 30

    • Session cookie header name: X-Qlik-Session-telegram

    • Anonymous access mode: No anonymous user

    • Authentication method: Header authentication static user directory

    • Header authentication header name: XXXXXXXXX

    • Header authentication static user directory: TELEGRAM

      Virtual Proxy.png

    • Save the "Header authentication header name" for later, as this parameter has to be used in the bot program. I have put it in red, but you can use whatever name you want, for example X-Qlik-TelHeadAuth.
  4. Get the code from jgerardoc/QlikSenseSDKConnectToServer · GitHub
  5. Edit the code, and put your "Header authentication header name" in the Program.cs module, where the function "QS.QSConnectServerHeader()" is called.
  6. Fill the rest of the parameters:
    • cntqsAppId with the app id. When you import the Consumer Goods Sales Bot app in your server, get the app id (for example from the URL, when you open the app in the hub)
    • cntqsServer with the path to the Qlik Sense server URL.
    • cntqsServerVirtualProxy with the name of the Virtual Proxy created in the step 3, if you used other different to Telegram.
  7. Run the program, and check the console messages. You have to see something similar to this:

Lesson 1 - Console Output.png

With this example, the program will open a connection to the Qlik Sense server, using the virtual proxy created before. I have used User1 for the UserID that is connecting to the server, so this user will be created if not exists in the User Directory specified in the virtual proxy (TELEGRAM in the snapshot). Be sure this user has access to the server, a token assigned, and rights to open the Consumer Goods Sales Bot application.

 

When the connection has been successful, the program will ask Qlik Sense to calculate the Sum of Sales Amount, to verify everything is working.

 

The diagram of this example is:

Lesson 1.png

The main program, a Windows Console application, will open the connection and then run the calculation using a Qlik Sense Utilities library I have called Qlik Sense Easy. This library will be the only point to "talk" to Qlik Sense, and I will be extending the functionallity in the next articles.

 

Next post, how to create a Telegram Chatbot and use it to send basic commands to Qlik Sense.

 

 

Juan Gerardo Cabeza

Qlik Iberia Presales

 

https://www.linkedin.com/in/juan-gerardo-cabeza-a414b825/