Last updated
Last updated
With this template, your customers can easily find your business' nearest branch by simply asking your chatbot! After asking the user for their address, the bot will look through an external database (Airtable) which contains the data for all your branch locations. Then it will calculate which location is closest to the user’s address by using the Google Maps API. Finally, the bot will show the result on Google Maps, within an iFrame.
Keep reading to learn how you can customise this template for your own organisation.
Make sure to always after loading a template!
This template uses two third party services:
Airtable, as a database for branch locations
Google Maps API, for finding the user address
To let your bot interact with these services you will need an API key for each and configure these in the Action blocks where the bot makes the API calls.`
If you have not worked with Airtable before, you can sign up for free and learn the basics .
For each of your organisation's locations, your Airtable will need fields with the following information:
Name of the branch
Address
Latitude
Longitude
When you’ve newly imported the 'Nearest Location' template, it will automatically link to . Feel free to use it for testing, but make sure to replace it once you start using the bot for your own organisation!
Below is an overview of the key blocks in each flow of the bot. Here we will walk you through how to configure the connection with the Airtable and Google Maps APIs, as well as some other tips to customise this template for your business.
In this block, the bot asks the user for their address and saves the response as a variable: user_address
.
To make this template work, your bot needs to be able to access the location data of your branch locations (in Airtable) and look up the user’s address (using the Google Maps API).
This block uses a Code Action to call both the Airtable API and the Google Maps API with the Javascript code shown below. This code may look a bit intimidating, but don’t worry, you only have to change a few pieces of information!
In this piece of code, you should customise the following three things:
The Google Maps API key
On line 13, replace (YOUR_GOOGLEMAPS_API_KEY)
with your own Google API key.
In this block, the bot shows the name and address of the closest location found in the database. The name is stored in the closestLocation.Name
variable and the address in closestLocation.Address
.
In this block the bot shows the closest branch location on a map, within an iFrame. In the Source Field of the iFrame action, also replace (YOUR_GOOGLEMAPS_API_KEY)
with your own Google API key.
Finally, in this block the bot clears the variable user_address
so the user can start the flow again and use another address.
Now that you've added this new flow, make sure it connects to other flows. For example, if this is an important use case for your bot, make sure to mention it in the introduction.
That's it, now your bot can find locations nearest to the user's address! 👏
For more information on how to integrate Airtable into your bot, check out .
Managing your branch locations in another database? You can link any type of database to this bot, as long as it has an API. Read more about our API integrations .
The Airtable link
In the url on line 1 of the code block, replace (YOUR_BASE_ID)
with the ID of your own Airtable base and (YOUR_TABLE_NAME)
with the name or ID of the table that contains your location data. You can find your Airtable's base and table IDs , or in the URL of your table view.
The Airtable API key
In the url on line 3, replace (YOUR_AIRTABLE_API_KEY)
with your own Airtable API key. You can find the API key on your .