One of the Best Places to Work is Hiring. Apply Now!

Alexa: Check out Salesforce’s New Geocoding Features

A few weeks ago, I was at my brother-in-law’s house checking out their Amazon Echo.  The kids were having a blast playing tunes and adding items to the shopping list.  Okay, maybe it wasn’t just the kids. I picked up an Echo and began tinkering with Alexa, Echo’s version of Siri.

Alexa comes with a standard set of  “skills” you can interact with.  The skills are kicked off by asking Alexa a question, such as “Alexa did the Twins lose yet again?” or “Alexa, did Blair Walsh miss another field goal?” In addition, Amazon provides a developer account and portal for creating custom skills.  Enter Salesforce’s new automatic geocoding feature.

One of my favorite features of the Summer ’16 release is the ability to automatically geocode standard Account, Contact, and Lead fields.  All in all, you can run a Data.com clean rule to automatically set latitude and longitude for four different standard addresses.  If you’re interested in learning more on the geocoding feature, see the following article on the release notes here: https://releasenotes.docs.salesforce.com/en-us/summer16/release-notes/rn_general_geocodes_aloha.htm

Side Note:  If you need to set custom addresses or automatically geocode custom latitude and longitude coordinates, consider running a trigger or process on a mock/dummy Account, Lead, or Contact and then carry over the coordinates to custom latitude and longitude fields.

Here’s where the light bulb went off.  Wouldn’t it be cool (maybe it’s just me) if you could ask Alexa when exactly you had to leave by, to make your next meeting on time?  Well, now you can with a custom Alexa skill, that queries for your next event/meeting in Salesforce, and then uses the Google Maps Distance Matrix API (https://developers.google.com/maps/documentation/distance-matrix/intro) to calculate the travel time.

Here’s how it works:

  1. The automatic geocoding Data.com cleaning rule is enabled for accounts.
  2. An account is created with a MailingAddress specified.  When the account is saved, the latitude and longitude are automatically populated.
  3. An event of type “Meeting” is assigned to you, and also relates to the account created in Step 2.
  4. You call an “utterance” by saying “Alexa: connect to Salesforce”.
  5. After Alexa responds with “Connected to Salesforce,” you issue a secondary utterance “Get Next Event”.
  6. This calls a node.js service hosted on Heroku.
  7. Heroku uses the nForce toolkit to call a custom Apex REST service in Heroku, which responds with your next event, including the latitude and longitude of the account associated with the event.
  8. The node.js service then calls the Google Maps Distance Matrix API with the latitude and longitude, and calculates the travel time.
  9. The node.js service then returns the information via the callback URL set when setting up the skill in your Amazon / Alexa developer account.

Looking to implement your own custom Salesforce Alexa skill? You’ll need the following:

In order to implement the custom skill, I followed the excellent “Echo Case Control” tutorial from Salesforce Developer evangelist Josh Birk (@joshbirk on twitter): https://github.com/joshbirk/EchoCaseControl.  Combining this with the node-googlemaps project (https://github.com/moshen/node-googlemaps), I now had the following app: https://github.com/dancinllama/EchoCaseControl

After pushing the app to heroku, I could now ask Alexa to connect to Salesforce and get my next event:

Have an idea for your own Salesforce and Alexa skill?  Feel free to fork my project (or Josh’s project) above and tinker away.


Written by James Loghry, Demand Chain Systems – Salesforce.com Architect and Salesforce MVP /Force.com MVP

James is an accomplished professional with over ten years ‘experience in the IT industry. Both a Salesforce MVP and Force.com MVP, James is certified in administration, advanced administration, development and advanced development.


Additional information on DCS Salesforce Development available on our Salesforce Development page.

Also, if you’re interested in learning more about our Salesforce admin services or consulting, please contact us at info@demandchainsystems.com.

Facebooktwittergoogle_plusredditpinterestlinkedinby feather
Facebooktwitterlinkedinby feather

No Comment

Comments are closed.

You may also like

Lube-Tech

Case Study: Lubrication Technologies Lubrication Technologies, Inc. (Lube-Tech) is an innovative lubricants company offering a broad ...
Read More
Salesforce DX

Salesforce DX: What is it and how do I prepare for it? Salesforce DX, arguably the ...
Read More