Google Sheets Integration/Add-On

Instantly populate your spreadsheet with data on people, organizations, articles and more from the Diffbot Knowledge Graph.

The Diffbot for Google Sheets Add-on allows you to leverage the power of the Diffbot Knowledge Graph from within Google Sheets. The Diffbot Knowledge Graph can help you quickly gather information from the public web, including information about People, Organizations, Products, Articles, and Discussions as well as enhance your existing data so that it will never be incomplete or out of date again.

Installation

To Install the Diffbot Google Sheets Add-on, visit the Diffbot for Sheets listing in the G Suite Marketplace:

1868

From here, click Install, choose the Google account that you’d like to use Diffbot from and grant Diffbot permissions. This is needed so that the Add-on can access your Google sheets spreadsheets, and connect to your Diffbot account. Diffbot will never share your personal data and the contents of your spreadsheet are never stored by Diffbot, only used to query the Knowledge Graph and fetch information from Diffbot to you.

978

After installation, you will see this success message. Diffbot for Google Sheets is now installed.

929

Quick Start

After installation, you will now be able to access Diffbot Knowledge Graph from any Google sheet. Let’s open a blank Google Sheet.

799

You will now need to log into Diffbot. Go to the Add-ons menu and select Diffbot for Sheets > Login to Diffbot.

Here you will need to enter your Diffbot API token. If you do not have a token, simply register for one at https://app.diffbot.com/get-started. After registering for an account, you will be able to view your token on the My Profile Page.

942

Enter your token and hit OK. You are now ready to use Diffbot in your Google Sheet.

Let’s find the homepage, location, and number of employees at Diffbot.

Pick any cell and enter the formula

=DQL("type:Organization name:'Diffbot'", "name,location,employees")
1106

As you type "DQL", you will see a help prompt come up. DQL stands for the Diffbot Query Language, and is the syntax for querying the Diffbot Knowledge Graph. You can learn more about DQL here.

The DQL custom function takes in the DQL query, which is the way to ask the Diffbot Knowledge Graph a question, the fields, which specify which fields of those entities you would like to write into your spreadsheet cells, and an optional size, which determines how many entities will be returned.

So this DQL function asks the Knowledge Graph for all entities of type Organization that are named Diffbot and specifies that we want the homepage, location, and number of employees. The multiple fields are separated by commas and will be returned as a row of three cells. Multiple entities would be returned in multiple rows.

1007

You can see the result of running that function. Congrats! You've made your first Diffbot Knowledge Graph query. Continue reading to learn about other custom functions.

Commands

DQLQueries the Diffbot Knowledge Graph using the Diffbot Query Language (DQL)
dql_queryThe DQL query. Not that single-quotes should be used in the dql query to avoid conflicting with the double quotes that surround the dql query.
fieldsThe field of each entity to display. You can also provide multiple separated by commas. You can also use "count" to just return a count of entities that match the query. Optional.
sizeThe maximum number of entities to return. Optional.
ENHANCE_ORGANIZATIONEnhances an organization using the Diffbot Knowledge Graph
fieldThe field of a Organization entity to return. You can also provide multiple separated by commas
nameThe provided name of the organization. Optional.
urlThe provided homepage of the organization. Optional.
locationThe provided location of the organization. Optional.
descriptionA description of what the organization does. Optional.
ENHANCE_PERSONEnhances a person using the Diffbot Knowledge Graph
fieldThe field of a Person entity to return. You can also provide multiple separated by commas
nameThe provided name of the person. Optional.
emailThe provided email of the person. Optional.
employerThe employer of the person. Optional.
locationThe location of the person. Optional.
descriptionThe bio of the person. Optional.
NLP_SENTIMENTAnalyzes sentiment of the text with Diffbot's natural language service
textThe text to analyze
NLP_ENTITIESReturns back the entities found in the text
textThe text to analyze
sizeThe number of entities to find in the text. Optional, defaults to 1.

Field Expressions

The DQL(), ENHANCE_PERSON(), ENHANCE_ORGANIZATION(), and NLP_ENTITIES() functions all take a fields parameter, which determine which fields of the entity to show in your spreadsheet cells.

In addition to requesting multiple comma-separated fields, you can also restrict which fields to return when there is a json array. For example,

=DQL("type:Organization name:'Home Depot'", "yearlyRevenues[*].{year:2018 revenue.value}", 1)

Will return the revenue of Home Depot just for the year 2018.

Tips & Tricks

  • Because quotation marks have value inside of Google Sheets functions, you’ll need to change all quotes within your Diffbot Query Language query to single quotes and wrap the entire function in double quotation marks.
  • Working with multiple DQL formulas across an entire column may be troublesome as Google Sheets will re-run the DQL for each cell on any change. To work around this, once you're satisfied with the output of a query, copy the data and paste "values only" into a new sheet.
  • Google Sheets limits the number of external connections that can be made from a sheet as well as the maximum number of simultaneous connections to external services. If you need to download thousands of records of data, export a CSV from the Dashboard instead.