This is not an officially supported Google product. It is a reference implementation.
This tool is a JavaScript (Angular) and Python solution to showcase an integration between a Gmail add-on and the Drive API. It saves attachments from selected emails in Gmail to a Drive parent folder. Once the Gmail add-on saves the attachments, the attachments are categorized with a special naming convention. Then a simple Python web application surfaces those categorized attachments via the Drive API.
-
Ensure Python 2.7 is installed.
-
Download the Google Cloud SDK for your platform.
-
Download the Google App Engine Python SDK for your platform.
-
Clone or download this repository to your computer:
git clone https://github.com/google/knowledge-base-gmail-addon
-
For App Engine environment, a vendor lock-in is needed for the third-party tools that are used in the application. Run the following command to install those:
pip install --no-cache-dir --upgrade --quiet --target lib --requirement requirements.txt
This will save a local copy of all the required third-party tools to a lib
directory.
Now, you can choose to either run this locally for development purposes, or deploy the application to App Engine.
-
Use
dev_appserver.py
to run the application locally:dev_appserver.py app.yaml
-
Visit
http://localhost:8080
to view your application. -
You can also view the local App Engine dev console by visiting
http://localhost:8000
.
-
Use
gcloud
to deploy the application, you will need to specify your Project ID:gcloud app deploy --project=your-project-id
-
To view your newly deployed application running, you can open a browser with:
gcloud app browse --project=your-project-id
On first run, you will be prompted for a username and password by HTTP basic auth. The default username is admin
and password is admin
.
Once the application is running we can change a few of the defaults that have been set up by the application's initialization.
- Open a browser and navigate to your newly locally running or App Engine deployed application. Remember, you may be prompted for a username and password by the basic auth scheme. The default username is
admin
and password isadmin
. - To view your application's settings page, click the menu icon (three dots) that is located in the top-right corner of the application.
Now that you are on the settings page, you can choose to change the HTTP basic auth username and password if needed. This is recommended. Take note of any changes.
The settings screen also allows us to set a Client ID
and config.json
for the application to use as authorization for the Campaign Manager API and Sheets API calls. To gather these credentials:
- Create a new project in the Google API Console.
- Click on the
+ ENABLE APIS AND SERVICES
button. - Find and enable the
Google Drive API
. - Go back to the APIs & Services dashboard and click the
Credentials
tab. - Configure a new
OAuth client ID
by clicking theCreate credentials
button. - If needed, configure the consent screen.
- Choose
Web application
and pick a name for your new application. - Add your application's local and App Engine URLs to
Authorized JavaScript origins
andAuthorized redirect URIs
. - Download the JSON file, open it in a text editor, and copy its contents into the
config.json
field of the settings page.
Load the code provided in the add-on
folder into Gmail as an add-on.
Within the Gmail add-on actions menu, go to the Settings action and set the following:
Parent Folder ID
xxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxx
Filters JSON
{
"Product" : ["Display & Video 360", "Campaign Manager", "Search Ads 360", "Google Analytics", "Studio"],
"Type": ["Runbook", "Release Notes", "Help Center"]
}
Information on App Engine:
Python on App Engine:
Running a local server for App Engine applications:
https://cloud.google.com/appengine/docs/standard/python/tools/using-local-server
- Tony Coconate ([email protected]) โ Google