Scheduled e-mails from embedded Tableau visualizations

UPDATE 2019-04-09: The previous versions of this blog post suggested ending the URL you input into the Tableau Settings box with with a “?=” to allow your application to listen to the Tableau view URL as a GET parameter. This does not work in more recent versions of Tableau Server. Tableau Server appears to separate out the “?=” and put it at the end no matter what.

Big thanks to Reed Walton at Tableau for coming up with the basics of this solution off the top of his head so many years ago.

Scheduling e-mails is easy in Tableau Server — as long as an SMTP server has been specified in the “Configure Tableau Server” program, there will be an e-mail subscription icon in the top of a viz when the user has permissions. The e-mail that is sent includes a PNG snapshot of the viz with a link to go directly to the view in Tableau Server. This poses a problem if you are embedding the views in your own portal and only want users to experience the embedded experience, as they will hit the Tableau Server vizportal UI directly, without the ?embed=y parameter and without any single sign-on.

Setting up Tableau Server for e-mails to go to a “redirect location”

Whatever you put in the “Tableau Server URL” box of the Notifications->Email Server page will have one of the following four patterns appended to it (the first two for Default Site, and the second if a non-default Site)

  • /views/{WorkbookContentUrl}/{ViewContentUrl}
  • /views/{WorkbookContentUrl}/{ViewContentUrl}/{username}/{CustomViewUrl}
  • /t/{siteContentUrl}/views/{WorkbookContentUrl}/{ViewContentUrl}
  • /t/{siteContentUrl}/views/{WorkbookContentUrl}/{ViewContentUrl}/{username}/{CustomViewUrl}

When the e-mail is sent, it will combine your “Tableau Server URL”  setting with these endings. The trick here is that instead of putting in the actual URL of your Tableau Server, instead you put in a URL that goes to your web application. It doesn’t have to be a plain fully-qualified domain — you can make a complex pattern.

For example, if we entered

https://myapp.mydomain.com/analytics/inbound/”

in the “Tableau Server URL” box, then an e-mail scheduled from the “emea” Site on my Tableau Server on the Workbook/View with contentURL: “EUMigrationCrisis/Wherethemigrantstravel” would end up like the following in the e-mail:

https://myapp.mydomain.com/analytics/inbound/t/emea/views/EUMigrationCrisis/Wherethemigrantstravel

Redirecting from the Link

This is where your own application environment will determine how you actually implement the solution, however there are multiple ways which all should work.

The process involves:

  1. When a URL that follows the pattern from above comes in (specifically the portion from the “Tableau Server URL”), recognize it for further processing
  2. Grab everything after the “Tableau Server URL” portion, and pass it to the page in your Web Application that displays Tableau Content
    •  You can split this portion up into its components, but it should match exactly to what is needed to load a view using the Tableau JavaScript API

How do you actually do this?

In an application like Node.js (JavaScript) or Django (Python), you may already be defining URL Routes which can translate URL components into arguments to send to a view function / method (Django example with some missing angle braces):


path('email/t/str:site/views/str:workbook_content_url/str:view_content_url/', views.tableau_content, name='tableau-content-email'),
path('email/t/str:site/views/str:workbook_content_url/str:view_content_url/str:username/str:custom_view_url/', views.tableau_content, name='tableau-content-email-custom-view'),

You might instead process the URLs at the web server level right when the come in and rewrite them as GET requests to a given active page:

https://myapp.mydomain.com/analytics/inbound/t/emea/views/EUMigrationCrisis/Wherethemigrantstravel

translated to:

https://myapp.mydomain.com/analytics/tableau_content.php?view=t/emea/views/EUMigrationCrisis/Wherethemigrantstravel

These are just examples, but hopefully with the principles defined, you’ll be able to accomplish this in the environment your existing web application exists in without too much trouble.

Leave a comment