I like systems that magically produce insights. Google Apps Script is well-positioned for automatically building comparisons because it has a fully-baked script trigger system for automating almost anything. Apps Script also has the ability to scrape content, but not with great precision1. For that, you need a headless browser like Browserless. The PaLM 2 API sweeps in behind the headless browser to accomplish two tasks:
Extract the features from the website text.
Generate comparative insights between each product.
In this sense, this script chains together multiple PaLM 2 inference calls like LangChain is often used.
My approach looks like this. It is general enough that you can use this script as the basis for many types of content capture and report writing.
Browserless Integration
A key requirement for this combination of scraping and AI examples is to capture the features of each product. In this case, I’ve scripted the example to compare CyberLandr with two other products - Form Camper, and SpaceCampers.
In the script provided below, the home page of each product is retrieved using REST API calls to the Browserless API, which returns a JSON array of all paragraphs in the web page. This makes compiling this content into a clean prompt to extract a feature list very easy.
Unfortunately, PaLM 2 doesn’t yet provide open access to the web. Ideally we might eliminate the Browserless by simply using a prompt like this.
You’re an AI that reads web pages and converts them to plain text.
Extract the text from https://cyberlandr.com and summarize the features into a concise list.
Someday soon, this will be possible. In the meantime, Browserless does a great job converting the paragraphs into a JSON array, which is easily transformed into a plain text prompt2.
The Briefing Document
This is what the script generates.
Main Function
The primary function is competitiveAnalysis()
. When you run it, it will perform the feature extractions from the home pages of each RV camper as defined in the product comparison array3.
Next, it will create a competitive assessment between the first product and each of the other products. Lastly, it will write the final report into a document in Google Drive in the Markdown format.
Google Apps Script
This is the complete source code for this example app. You can use this as a template for many types of comparisons. You are free and encouraged to build whatever you want from this code.
Keep reading with a 7-day free trial
Subscribe to Impertinent to keep reading this post and get 7 days of free access to the full post archives.