Skip to main content

Prerequisites

Before you connect, you must first do the following:
  • Connect a data source to your Connect AI account. See Sources for more information.
  • Generate a Personal Access Token (PAT) on the Settings page. Copy this down, as it acts as your password during authentication.

Connect to Connect AI

In order to connect from Apps Script to Connect AI via the Query API, you need the following information:
1
Log in to Apps Script (https://script.google.com).
2
Create a new Apps Script project.
3
Copy and paste the script below into the Apps Script project. This script connects your data source to the Query API and outputs the results to the Apps Script console. Change the following in the script:
  • Update username with your Connect AI username.
  • Update password with the PAT you generated in the prerequisites.
  • Update query with your database query.
4
Name and save your Apps Script project.
5
Run the script.
The first time you run the script, you need to authorize it to make external connections. Click Review Permissions and follow the prompts to grant the necessary permissions.
6
The Execution log displays the query output as a JSON object: