Simplest Way To Sending Dashboard Image Integrated Tableau Server Client & LINE MessagingAPI

Phakorn Intassingha
4 min readJun 8, 2022

Introduction

Tableau is one of the most common Business Intelligence tools (BI tools). the application of the BI tools provides an interactive dashboard composed of charts and graphs to help users to understand, analyze, finding insight into the data in their own business. Tableau has 2 main products; 1. Tableau Desktop is a tool for building the interactive dashboard. once you build the dashboard completely, you have to use the second service to publish and share with other people in your organization which is Tableau Server. Tableau Server has an API called Tableau Server Client which allows the user to pull, and request any contents on the user’s server based on Python.

The problem is some user (e.g. manager, director, chief) doesn’t want to directly log in to the server to discover the whole contents of the server but they just want to monitor quickly once per day e.g. How many sales yesterday?, What product should be restocked? etc. Thus, I’ll bring you to drive through to the solution via this blog.

Hello everyone, this is Episode 1 for the Tableau technique. I’m gonna share the application of the Tableau Server Client integrated with LINE Messaging API to send a dashboard image from the Tableau server to the user via the LINE platform.

What will you get?

It’s a kind of tutorial or maybe a guideline for you to develop the application.
First, I’ll explain an overall of our process before we start!.
As the architecture below, sending the dashboard image to users via LINE platform has to use LINE Messaging API to be a middle tool to communicate between a localhost server and users (like a chatbot). The localhost is a server that is set on your own PC by using ngrok to put localhost online on the internet. Responsibilities of the localhost in this process are storing the exported dashboard image from the tableau server via API and being a Webhook of LINE Messaging API.

Prerequisites

  1. Tableau Server
  2. ngrok Download Link Windows 10 x64
    Sign up then Login https://ngrok.com/ and follow a setup & installation on the website.
execute 1, 2 commands to enable ngrok on your PC.

3. Python 3.8+

pip install tableauserverclientpip install flask

Steps

  1. Create a python file named config.py in the format below. For the channelAccTkn will be got later step.
"config.py"
username = 'TABLEAU SERVER USERNAME'
password = 'TABLEAU SERVER PASSWORD'
channelAccTkn = 'CHANNEL ACESS TOKEN (Messaging API)'

2. Get started to export a dashboard from the tableau server to store to the localhost by using tableauserverclient library. Afterward, define your tableau server address, site_id, and target_view (a target’s name of a dashboard will be exported).

get_image.py

2.1 The result of executing get_image.py is the image of the target dashboard that collected into [root]/static/images/{target_view}_{export date}

result of executing get_image.py

3. Create a LINE Messaging API to get the channelAccTkn. Then copy the token to config.py

https://developers.line.me/en

For the method of setting Messaging API please google :P

4. Start ngrok.exe to put the localhost on the internet by the command below.

ngrok http 5000

4.1 Copy https://xxxx-xxxx-xxx.ap.ngrok.io from the Forwarding topic and paste it to the messaging API > Webhook settings> Webhook URL and click Update> Verify

ngrok.exe interface
LINE Messaging API in Webhook setting menu

5. Create a chatbot via Flask as script app.py below and deploy it on the localhost server. before executing please edit your filename, endpoint (use https://xxxx-xxxx-xxx.ap.ngrok.io that copy to Webhook earlier).

6. Execute app.py and type the keyword that is defined in the flask “dashboard”

ngrok interface after execute app.py

What’s next?

If you want to schedule send the dashboard image please deploy the python script to a cloud service such as AWS lambda.

Simple architecture of scheduling sends dashboard image to the LINE User

For more information: https://aws.amazon.com/lambda/

Best,
Phakorn Intassingha
Associate Data Analyst
LinkedIn: https://www.linkedin.com/in/phakorn-intassingha-6041b0194/

--

--