/ Azure

Creating an intelligent real time twitter dashboard

You need a PowerBi account so you can not use your personal email address to finish this tutorial

In this post I will show you how you can easily build a real-time PowerBi dashboard showing you your favorite trending Twitter hashtag. We will enrich the data (tweets) with some intelligence from the Microsoft Cognitive services.

What we will need:

  1. PowerBI account, if you do not have it yet you can create it here.
  2. Azure account, if you do not have it yet you can create it for free here.
    Services to use:
  3. Azure functions
  4. Logic apps
  5. Cognitive services account, create one here if you do not have it.
  6. Twitter account, can be some test account.

Lets get started

Log into Azure via portal.azure.com, create a new Logic app like this:

When the logic app is created you should be directly redirected to the designer interface which should look as follows:

Logic app designer

The first thing we are going to add in the 'Trigger', in our case the Trigger is 'When a tweet is posted'. This means our flow will be fired when a Tweet is posted with our search term. When the Tweet trigger is selected, you have to quickly log on with you twitter account (nothing will be posted of course), we can enter our search term as follows:

Just fill out the search term which you want search for, in my cast i will be searching for #Microsoft, with a frequency every 3 minutes. As said in the beginning we will not only be showing real time Tweets we will also add intelligence, for this we will be using Microsoft Cognitive services.
So press the big 'New step' --> 'Add an action' button and search for the step 'Text analytics - Detect sentiment'.

Next you have to get the API keys for text analytics, these are freely available here, just log in once logged in go to 'My account'. Press the big plus button and add 'Text Analytics', once done you should have two keys. Just copy one key and add this in the logic app which should look as follows, the name of the connection can be anything:

Simply click create, when done you should set the text whihc you want to be analysed which could be done as follows:

As you can see we add 'Tweet text' as input for the Detect Sentiment step we use the twitter text.

We only have one step namely pushing all this data to the PowerBi dashboard.


Create a streaming PowerBi data set

If you have come to here it will be smooth sailing from here.
Login to you powerbi account at powerbi.com, then navigate to you data sets by clicking on your profile picture on the left side of the page.

At the top right you can press the plus button to create a new streaming data set.

Choose the 'API' option and go on to the next page. Here we will define our data set, you can define your variable names and types here. I will add 3 variables for now but feel free to extend this to you own liking. Make sure you check the 'Historic data analytics' slider

Once this is created, go back to you logic app. Add a new step and search for 'Power BI' then add this step which should look as follows:

Simpy sign-in with your account. Once logged fill out the fields in my case it looks like this, if you created your data set on a different work space make sure you select the proper work space.

Once setup save your result, press the big play button and wait until a tweet with your given search term is tweeted.


Creating the dashboard

Putting real-time data in PowerBi is only cool if you actualy have a dashboard to show this data, so lets do it!
Go back to your data sets where you have also made your streaming data set and find the data set. Once you found the data set click on the graph icon as shown below.

If you have used PowerBi before start creating your dashboard now, for the less experienced I will show two sample visualizations.

First I am going to make a counter of the number of tweets. This is extremely easy just check the variable text, select 'Card' visualisation and make sure the variable is set to 'Count'. It will all look like this:

Easy enough right?

Secondly lets make a graph with the sentiment over time, from the last 100 tweets.

Here simply select both the Date and Sentiment field, click the proper visualization as shown above and apply a filter also shown above.

Lastly we want to pin these visualizations to a dashboard, to do this simply hover over a visualization and click the pin icon. Do this for both the visualizations which we created.

Now navigate to your just created dashboard and see the counter go up every time a tweet is tweeted!

If you have any questions just leave a reply!

Cheers,

Vincent van Wingerden

Vincent van Wingerden

I work for Microsoft as Technology advisor on the area of big data and advanced analytics. When I have made another cool demo I hope to write about it here. All opinions are my own

Read More