ListingAI Demo

HTML

<input 
  onClick="callAPI()" 
  type="button"
  class="basic-btn"
  id="generateBtn"
  value="Click to generate"
  />

<pre id="apiResponseField">
  Your description will show here.
</pre>

CSS

pre {
  width:300px;
  border:1px solid black;
  padding:10px;
  white-space: pre-wrap;
  text-align:left;
}

.basic-btn {
  cursor: pointer;
  border: 1px solid black;
  width: 120px;
  border-radius: 10px;
  padding: 5px;
  text-align: center;
  background: lightgrey;
}

JavaScript

var callAPI = async function() {
  
  //disable the generate button so it cant be clicked twice
  const generateBtn = document.getElementById("generateBtn");
  generateBtn.disabled = true;
  
  //provide feedabck to the user
  const responseField = document.getElementById("apiResponseField");
  responseField.innerText = "Running...";

  const data = {
	  //required fields
  	address: "152 Strachan Ave Toronto Ontario M6J2S9 Canada", //Note: Until you provide a production API key, API will only work with this exact address.
    propertyType:"deatched house",
    transactionType:"for sale", //'for sale' or 'for rent' etc
    numberOfBedrooms:3, //if not applicable provide 0
    numberOfBathrooms:3.5, //if not applicable provide 0
    numberOfParkingSpaces:2, //if not applicable provide 0
    writingStyle:"custom", //relaxed, formal, luxury or custom
    communityHighlights:null, //in the format of a Google places API location result (https://developers.google.com/maps/documentation/places/web-service/place-id#places-api)
    communityHighlightsDiscovery:"city", //acceptable values are "point", disabled", "city" or "property_addresss".
    //if using point you must provide the lat/lng of the point
    /*
    communityLongitude -79.4129782,
    communityLatitude: 43.6442542,
		*/
    tone: "professional", //casual, professional or creative - ignored unless writing style is "custom"
    complexity: "intermediate", //simple, intermediate, or advanced - ignored unless writing style is "custom"
    language:"en-US",
    //if no rules are intended to be provided simply input empty array []
    instructions: [
    	"If the property is in Florida, refer to any porch as a lanai",
      "The word \"home\" prefered over alternatives such as \"property\", \"abode\", \"residence\" etc.",
      "When writing addresses in descriptions avoid including the zip code",
      "Parking should always be described as being in the context of a garage",
      
    ],
    //if no rules are...