In this article we will learn OmniScript Address Autocomplete with Google Places Api. This document provides a step-by-step guide to configure Salesforce OmniScript’s built-in Type Ahead element to perform address autocomplete using the Google Maps Places API. With no Integration Procedures or Apex code, you will: supply your API key, configure the Type Ahead block, and map address components into Street, City, Postal Code, Province/State, and Country fields.
Prerequisites for OmniScript Address Autocomplete with Google Places Api
Before you begin, make sure you have the following:
- Google Cloud Account: You need an active Google Cloud project with billing enabled.
Obtain Your Google Places API Key
- Sign in to the Google Cloud Console.
- Select an existing project or click New Project to create one.
- In the left menu, navigate to APIs & Services → Library, search for Places API, and click Enable.
- Go to APIs & Services → Credentials and click Create Credentials → API key.
- In the API key created dialog, give the key a name (e.g., OmniScriptPlacesKey).
- Click Restrict key, under Key restrictions choose HTTP referrers (web sites) or IP addresses as needed, then under API restrictions select Restrict key → Places API → Save.
- Copy the generated API key—you’ll paste it into the Type Ahead block.
1. Add a New OmniScript Step
1. Navigate to OmniStudio → OmniScripts in your Salesforce org.
2. Open your existing OmniScript or create a new one.
3. Click + to add a Step, and label it Enter Address.
2. Lay Out the Address Fields
1. Inside the Enter Address step, drag in a Type Ahead element for user input.
2. Below the Type Ahead, add five Text elements, labeled as follows:
– Street
– City
– Postal-Code
– Province / State
– Country
3. (Optional) Use a Line Break element between rows for clean spacing.
3. Configure the Type Ahead Block
1. Select the Type Ahead element, then switch to the Properties tab.
2. Expand Google Maps Autocomplete and configure:
– Hide Map: ☑ (if you do not need the embedded map)
– Google Maps API Key: <YOUR_GOOGLE_PLACES_API_KEY>
– Country Filter: (Optional) specify a country code (e.g., US, CA) or leave as All.
3. Under Google Maps Transformation, click Add for each component and map as follows:
Label | Google Response Path |
Street | street |
City | address_components:locality |
Postal-Code | address_components:postal_cod |
| Province /State | address_components:administrative_area_level_1 |
Country | address_components:country |
> Each mapping will automatically extract the .long_name field for you.
Also Read: How to pass Data from Omniscript to Custom LWC?
4. Bind the Selection Output
1. In the Properties panel under Build, locate Selection Variable and name it SelectedAddress.
2. This variable now holds the JSON payload returned when a user selects an address suggestion.
5. Map Address Components via Transformation
Since you’ve configured the Google Maps Transformation on the Type Ahead block, each downstream Text input will receive its value directly without needing separate JSON Path mappings. To ensure correct binding:
1. Edit each Text element and verify its Element Name in the Build tab matches the corresponding Child Element above.
2. Save your OmniScript—no additional JSON Path is required on the Text inputs.
6. Test & Validate
1. Click Preview on your OmniScript.
2. In the Enter Address step, begin typing an address (e.g., “1600 Amphitheatre Parkway”).
3. Select a suggestion from the dropdown.
4. Verify that the Street, City, Postal-Code, Province/State, and Country fields populate correctly.
5. Test edge cases (invalid inputs, unsupported countries) to ensure graceful handling (e.g., clear fields or display “No results”).
7. Tips & Next Steps
– Styling: Apply CSS classes on Text elements to fine-tune alignment and spacing.
– Country Restriction: Set the Country Filter to your primary region to minimize API usage and improve relevance.
– Additional Components: Add further mappings (e.g., neighborhood, sublocality) by repeating the mapping steps.
– Error Handling: Use a Conditional Element to display a custom message when %SelectedAddress% is empty.
Conclusion: OmniScript Address Autocomplete with Google Places Api
By leveraging OmniScript’s native Type Ahead block, you enable full address autocomplete capabilities with minimal configuration and zero code. This declarative approach speeds development, reduces maintenance, and delivers a superior user experience.
Feel free to insert screenshots in place of placeholders, and update variable names to match your org’s conventions. Let me know if you need further enhancements or styling guidance!