How to Send Text Messages in Tableau + Why You'd Want to
Note: The following is a guest post by Tableau enthusiast Jeffrey Shaffer.
What can you do with a simple text-messaging application in Tableau? As one Tableau user put it (in Estonian), the possibilities are endless.
— Datafruit (@datafruitBI) June 18, 2015
Here are some ways to leverage a text-messaging application in Tableau:
- A report that has been updated or modified could include a button to notify a user. (i.e. “Executive dashboard has been updated.”)
- Key Performance Indicators could be established, and with a click of a button, the KPIs could be evaluated and a text message could be sent. (i.e. “Inventory level is below expected level.”)
- A confirmation text could be sent when a user enters certain information. (Combine this with Tara Walker’s method for turning a viz into a poll, and add a confirmation text message. Tableau could assign a random confirmation code and send that to a user in a text message. Then utilizing another parameter, the user could enter that confirmation code to match.)
- A user could send a text message to the report author to share comments or to report a problem.
- A button on the viz (like "Enter” or “Next”) could trigger text messages to the author. (i.e. “Someone is looking at your viz right now,” or “Someone searched for John Smith.”)
I’m sure the Tableau community will have many more ideas to add to this list.
How to Text Using Tableau
Let me walk you through creating a viz that sends texts directly from Tableau. It’s pretty straightforward; it uses a few parameters and a URL action.
Step 1: Create a New Tableau File
- Open Tableau and choose “Create a New Tableau Worksheet” (under the File tab).
- Open Microsoft Excel and enter “Label” in cell A1 and “Send” in cell A2. Copy these cells.
- Go back to Tableau. Select Data, and choose “Paste Data.”
- Select Shape on the Marks card, as shown below.
- Click on Shape and select a shape to go with “Send” (an arrow, for example).
- Rename “Sheet 1” as “Send.”
Step 2: Sign Up for a Clock Work SMS Account
- Signup is free on Clock Work's website. Once you confirm your account you, will receive a 50-cent credit. Text messaging is 3 cents per message sent in the US. Other countries are available at different rates.
- Obtain an API key and copy this to the clipboard.
Step 3: Build a Simple Text-Messaging Viz
- Create a new calculated field called “API.”
- Paste the API key from the clipboard into the field in quotes, and click OK.
- Create a new parameter named “Phone Number” and set the Data Type to “String” with the current value empty.
- Create a new parameter named “Message” and set the Data Type to “String” with the current value empty.
- Create a new calculated field named “Message Formatted” and enter the following formula: REPLACE([Message]," ", "+"). This will replace the spaces in the message with a + sign for the URL we will build.
- Add “Message Formatted” and “API Key” to the Details shelf.
- Create a new dashboard.
- Place the “Send” worksheet on the dashboard.
- Right-click on the “Send” title and click on “Hide the Title.”
- Right-click on “Label” and click on “Hide Field Label for Rows.”
- Click on the dropdown options in the top right-hand corner and select each of the parameters. This will add them to the dashboard.
- Click on the Dashboard menu and select Actions.
- Click on Add Actions and select URL.
- Choose Run Action on “Select.”
- Enter the following URL into the URL box:
https://api.clockworksms.com/http/send.aspx?key=<APIKey>&to=<Parameters.Phone Number>&content=<Message Formatted>
You should now have a working text-messaging viz. Test the URL by entering a phone number (if you are in the US, make sure to include a “1” and the area code), adding message on the dashboard and clicking on "Send." A webpage should open and give the status of the message.
If you have a valid API key, then your text should deliver and return a confirmation message in the browser:
If the API key is invalid, then an error 58 will return:
- Format the dashboard as you prefer.
Step 4: Embed the Webpage (Optional)
If you would like to avoid having a webpage window pop up, add a webpage object to the dashboard.
- Drag “Webpage” to Dashboard.
- Enter the following URL to create a blank webpage object on the dashboard:
- Now the confirmation notice will return on the dashboard in the webpage object.
Now that you have the know-how, how will you leverage text-messaging in Tableau? Share your ideas in the comments below.
Jeffrey Shaffer is a data visualization professor at the University of Cincinnati. You can find additional insights from Jeffrey on his website, dataplusscience.com.