Set Up OmniScript Type Ahead Autocomplete with the Google Places API

In this post, we are going to learn how to set up OmniScript Type Ahead autocomplete with Google Places API. You’ve seen this implemented in most forms that require input for an address and then as you type the address autocompletes and optionally we see it populates other fields in the form like the street name, state/suburb, postal code, etc.

It is easy to set this up in OmniScript with the TypeAhead block.

Google Maps API

In order to call the Google Maps API, we would need a key that we would use for our request.

First, let’s set up the Google API key.

Sign up for a Google cloud account, this is free. Next, access the console.

Then create a new Project and give it a Name.

Autocomplete Google Maps Api

Next, from the menu go to API & Services

Autocomplete Google Maps Api
  • Select Credentials
  • Click on + Create Credentials
  • Select API Key
  • Copy the key
  • Open the key and rename it to something meaningful eg. Maps key
  • You can put application restrictions
Autocomplete Google Maps Api

Keep copied key handy and now we can proceed with the OmniStudio Omniscript TypeAhead Setup

Salesforce Remote Site Settings

Go to Salesforce and add the following Remote Site settings.

  • Setup > Quick Find > Remote Site Settings
  • Click New
  • Remote Site Name: MapsGoogleAPI
  • Remote Site URL: https://maps.googleapis.com
  • Active: true
  • Then hit the Save button. 

OmniStudio Omniscript TypeAhead

Now, create an OmniScript and give it a name, type, and a subtype

  • Under Build select TypeAhead and add the element to the canvas
  • Update the Type Ahead Block
    • Name: Address
    • Field Label: Address
    • Minimum Length 2
    • Go under Google Maps AutoComplete and paste the key
    • Country Filter: Set to your country for eg. New Zealand
  • Optional Add Google Maps Transformation

Go ahead and Preview and it should look like this.

Autocomplete Google Maps Api

Summary

So there you go, we learned to set up an OmniScript Type Ahead autocomplete with Google Places API.

I am currently working on an OmniStudio Udemy and Skillshare course where I will cover more about development and building on the framework. Will be an in-depth good resource for preparing for the OmniStudio Developer Certification.

If you are interested to know and want to be notified when it comes out. Show your interest by leaving a comment below.

Leave a Reply

Your email address will not be published.