Automate custom Tableau email updates

Like it or not, looking at you Slack, email remains the preferred way to disseminate information in the workplace. Volume is still growing, especially business emails volume growing at a cool steady annual rate of 7%. Is usage growing at the same pace? Meaning: are recipients actually reading those emails? That’s another issue…
Among your users, chances are that some are still heavily reliant, not to say tethered to email as they primary vehicle for sharing data. Even if you send a nice link to a perfectly crafted Tableau viz, they won’t click it, complaining it is too difficult to have to authenticate first, and wait for the browser to display, especially on a mobile device.

flying-emailsTherefore, there is still a case to be made for broadcasting data by email, as admitted very recently by Tableau. Starting with Tableau V10, you can finally subscribe on behalf of other users, whereas previous versions only let users subscribe for themselves. Tableau’s implementation is elegant and simple, as usual, but still comes with limitations:

  1. Each recipient must be licensed on the Tableau Server, which can get quite costly in a situation where you only need to send a sales updates to a large number of sales reps
  2. You are limited in terms of formatting options
  3. You cannot leverage existing Distribution Lists (DLs) maintained on your Exchange or other mail server

There is a better way, described in that post, that offers a much wider set of options, with a bit of R&D and very minimal coding. We will use a simple scenario: a large number of sales reps must receive a sales report by email at the start of their business day. This operation entails the following steps:

  1. Gather timely images of the reports out of your Tableau server, to be inserted in the email
  2.  Put together a script to assemble the email and send it to a Distribution List
  3. Automate and schedule the task (optional)

  • 1. Gather Images

    Of course you could use the manual download button in your report, then Image option, to download a nice PNG file. However, this could get tedious over time… A better approach is to leverage the handy TABCMD script tool that comes with Tableau Server. I have covered TABCMD in quite some depth in previous posts, here and here. In a nutshell, you can run it from Tableau server, or from your desktop if you don’t have access, after installing it following those instructions.

    Using TABCMD, you can develop a batch script, which will pull a series of images and write it to a folder location. Here is the sample code that you will save as a .BAT file:

    rem Pull Sample View
    tabcmd get “!/vizhome/CorrelationChomageetVoteFNauxEuropeennes/VoteFNauxEuropeennesvs_Chomage.png”  -f “TARGET PATH\Demo Report.png”
    tabcmd logout

    Rem command is used for comments. For the Get command, paste the URL of the viz you need and don’t forget to add the .PNG to get it saved as image, or .PDF if you fancy. If your URL has a /#/ after the server address, make sure you remove it. The optional Pause command keeps the window open to let you see what happened until you press a key. Of course, before the logout command, you can add additional instructions to perform in series, such as further images retrievals.

  • 2. Send the email to a DL

    This part requires a small investment into a command line email tool, that will let us script the email send part. I have been following Tableau recommendation and used Febooti, which works great. Note that Febooti offers a generous 40 days to try their solution for free before you buy. Here is the script which can be appended to the previous batch script, or as standalone:

    cd C:\Program Files (x86)\Febooti Command line email
    febootimail.exe -SMTP IPADDRESSFORYOUREMAILSERVER -TO “” -FROM -FROMNAME Tableau Reports -REPLYTO -SUBJECT “Test Febooti email %date:/=-%” -ATTACH “SOURCE PATH\Demo Report.png” -BODY “this is emailed through Febooti”

    the %date:/=-% string insert the sending date into the subject line. You can refine the model further by inserting the image in the body of the email, using an HTML template, which points to the image. Replace:
    -BODY “this is emailed through Febooti”
    -HTMLFILE “SOURCE PATH\yourtemplate.htm”
    If you are a bit rusty or unsure of your HTML, create in Outlook an email template that works, save it as a HTML file, open it in Notepad or better in Notepad++ and look for the <BODY> tag and insert before the </BODY> the following HTML Code:

    <a href=”URL TO THE TABLEAU VIZ” rel=”attachment wp-att-675″><img class=”aligncenter size-full wp-image-675″ src=”SOURCE PATH\Demo Report.png” alt=”Tableau Viz” /></a>

    HTML offers many formatting options for the template.

  • 3. Automate the execution

    Now that you have a nice batch file which can automatically pull the report from your Tableau server and email it to a DL of recipients from your Exchange email server, how to automate the execution every morning so that the sales reps can check the viz before the start of their busy day?

    By using the Alteryx scheduler… You can use the magic combo of scheduling a workflow which contains the Running Command tool pointing to your batch file, as described in this previous post or that one.You could even use Runner Macros to run parts of the scripts with Success/Failures dependencies.

    Once developed, those batch scripts run really fast and are fairly easy to maintain…

This entry was posted in Automation, Marketing, Sales, Tableau and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *