1. Home
  2. Docs
  3. Tutorials
  4. Use device address to personalize your application

Use device address to personalize your application

In this tutorial, we will learn how to use the device location in an Alexa Skill, a Google Home action or a Facebook Messenger bot, and use it to locate the nearest restaurant using Yelp Fusion API.


Some of the information in this guide is more developer-centric, but don’t be discouraged. If you follow the steps as they’re outlined, you will have a deployed, working “Find Nearby Resturants” app.

Create a Yelp Fusion account

The Yelp Fusion API allows you to get the best local content and user reviews from millions of businesses across 32 countries.

  1. If you don’t already have a Yelp developer account, sign up. If you have an account, log in.
  2. Create a new app at https://www.yelp.com/developers/v3/manage_app. Save the “API Key” we will need it later.

Create a conversational app

A Conversation.one application represents your conversational interface through Amazon Alexa, Google Home or Facebook Messenger bot. To create an app:

  1. If you don’t already have a Conversation.one account, sign up. If you have an account, log in.
  2. Click on Create New App in the navigation. If it’s your first application, you will be redirected to the Create New App wizard automatically.
  3. Select your industry and enter your company name. For the purpose of this tutorial, select “Other” for the industry, and enter “Find Restaurants” as your company name. Click Next to continue.
  4. Select the devices you want to support with your app. For this demo select Messenger, Amazon Alexa, Google Home, and Chatbot. Click Next to continue.
  5. When asked “What will the user ask your bot?” enter “Find Restaurant”, and click Next to continue.
  6. Select Code response, and enter the code:
    var apiKey = "YourYelpAPIKey";
    const yelp = require('yelp-fusion');
    const client = yelp.client(apiKey);
    return sdk.GetDeviceAddress(context, req, res).then(function(address) {
        var searchOptions = {
            term: 'restaurant'
        if (address.long != "" && address.lat != "") {
            searchOptions.longitude = address.long;
            searchOptions.latitude = address.lat;
        } else if (address.FullAddress != "") {
            searchOptions.location = address.FullAddress;
        } else if (address.Street != "" && address.City != "") {
            searchOptions.location = address.Street + "," + address.City;
        } else {
            res.say("Soory, I could not locate your address. Repeat your question using a full address.");
        return client.search(searchOptions).then(response => {
            var text = "I found " + response.jsonBody.businesses[0].name + ", located at ";
            text += response.jsonBody.businesses[0].location.address1 + "," + response.jsonBody.businesses[0].location.city + ".";
            var text = response.jsonBody.businesses[0].location.address1 + "," + response.jsonBody.businesses[0].location.city + ".";
            text += "";
            text += "Phone: " + response.jsonBody.businesses[0].phone;
                type: "Standard",
                title: response.jsonBody.businesses[0].name,
                text: text,
                image: {
                    smallImageUrl: response.jsonBody.businesses[0].image_url,
                    largeImageUrl: response.jsonBody.businesses[0].image_url,
    }).catch(e => {

    The code above is running the following steps:
    1. Find the user’s address using the function “GetDeviceAddress”
    2. Use the best option for the location search – GPS (log/lat), full address or street & city.
    3. Call the Yelp Fusion API using yelp-fusion client
    4. Return the result both as text and as a card

  7. Your new application is ready. Click Customize to complete your app.

Add entities

Entities are powerful tools used for extracting parameter values from natural language inputs. We will use entities in this tutorial to allow the user to provide a specific address, instead of the device configured address.

  1. Open the FindRestaurant intent
  2. Add a new entity named “Address” with type “Address”

Add more samples

  • Replace the existing “Users sais” sample with “(where is|what is|what’s) the (closest|nearest|nighest) (restaurant) ( | to {Address})”
  • Click Save

Try it out

Now that your app can return the nearest restaurant to the user, try out what you have so far.

In the chat console on the right, type in a request. The request can be a little different than the examples you provided in the User Says section. This can be something like “where is the closest restaurant “. After you type the request, hit “Send”.

The chatbot will answer with the details of the closest restaurant. For example “I found DishDash, located at 190 S Murphy Ave, Sunnyvale.”

Try now with a specific address. For example “where is the closest restaurant to 1 Market St, San Francisco”. The chatbot will answer with the details of the closest restaurant. For example “I found Hog Island Oyster Co, located at 1 Ferry Bldg, San Francisco.”

What’s next?

You can use the Amazon Alexa and Google Home deployment wizard to deploy your new application on the different platforms.

Was this article helpful to you? Yes No 1

How can we help?