How to Become a Chatbot Ninja in 7 Days

Module 3: Lesson 3.4. The Zillow API integration

Lesson 3.4. The Zillow API integration

If you are a realtor or cater to realtors in your business, this is a great lead generator. Your user can enter any address (USA only) and it will show a Google Streetview image of the address as well as an estimate from Zillow.

What you’ll need is this:

  • a little scripting in PHP;
  • an API key (ZWSID) from Zillow: https://www.zillow.com/howto/api/APIOverview.htm ;
  • an API key from Google Developers: https://console.cloud.google.com/apis/library;
  • some of ManyChat’s awesome Dynamic Content actions.

Ready? Let’s start looking up some properties

Creating our simple flow in ManyChat

We will create a flow where we will ask the user a few questions. In fact, you only need two answers to make this work: a street address and a zipcode or city. Without these variables it will not work, so make sure you check for empty values.

If you take a good look at the image above, you see the flow begins with a node called "The End". Now how is that? Obviously it starts with the Starting Step, but The End does not seem to be connected with anything. Weird. Or not? Nope, it is because the dynamic content script created a button in the end, with JSON/PHP code:

...
$textArray = array("type" => "text", "text" => $firstname.", we do have some more info on the property. Do you want to see more details for ".$search." on Zillow?");
$content['messages'][1] = $textArray;
$buttonsArray =  array("type" => "url", "caption" => "Yes, show me!", "url" => $homedetails);
$content['messages'][1]['buttons'][] = $buttonsArray;
$buttonsArray =  array("type" => "node", "caption" => "Another Valuation", "target" => "Get Property Info");
$content['messages'][1]['buttons'][] = $buttonsArray;
$buttonsArray =  array("type" => "node", "caption" => "I'm done, thanks", "target" => "The End");
$content['messages'][1]['buttons'][] = $buttonsArray;
...

A closer look at the Dynamic Response Call

To get the data from Google Maps for the streetview image and the Zillow estimate, we need to setup the call script inside ManyChat's Dynamic content node.

  • Click the Dynamic Response icon as shown in the image here. Then select the message box/field to enter your data.
  • At the Request URL form field, put in the location of the PHP file on your server.
  • Next, select the BODY tab below the Request URL form and put in the data as diplayed in this image.
  • Click the Test the Request link on the Right and see if you get a result

If you set up everything correctly, you should get a response like this:

The Response Body content should look like this:

{
    "version": "v2",
    "content": {
        "messages": [
            {
                "type": "text",
                "text": "Bummer, Paul\n\r\n\rWe did not find any property on the requested address. Please check what you've entered:\n\r\n\rAddress: \n\r\n\rZipcode: ",
                "buttons": [
                    {
                        "type": "node",
                        "caption": "Try Again",
                        "target": "Get Property Info"
                    }
                ]
            }
        ]
    }
}

 

Creating the PHP File

Now we are going to create the PHP file that retrieves the data sent from ManyChat to your server. We call it lesson.3.4.zillow.realtor.php

Please take notice of the three (3) highlighted lines, you MUST fill in your data there or it will not work.

Here are the links to get your API credentials once more:

Script: You need at least a Silver Membership to Access/Download this Content

The above should get you up and running your realtor lead magic pretty quick. You can implement it in your own templates to use for realtors or any other creative way.

Note: Make sure to ready the Zillow/Google rules though, you don't want to get your client's account shut down for silly reasons.

Downloads: You need at least a Silver Membership to Access/Download this Content