How to integrate Google services with Orbita
Orbita lets the Voice Experience developer integrate Google services with Orbita’s project. This allows the Voice Experience developer to retrieve or send data to Gooogle services. Orbita exposed a middleware function to get the JWT tokens from Google. You have to enable the Google services that you are going access using the JWT token.
For example, as a Voice Experience developer, you may want to export the completed survey data to Google drive (doc/sheet).
This document details how to integrate Google Drive with Orbita.
Â
Integrate Google Drive with Orbita’s project.
Get JWT Token in Experience Designer
Login to Orbita and open Experience Designer.
Add the below code in the function node or import the sample flow attached.
var orbitaUtil = global.get('orbitaUtil');
var resPromise = orbitaUtil.getGoogleAuthJWTToken({ client_email: "<ABCD@EFGH.iam.gserviceaccount.com>", private_key: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBg...\n-----END PRIVATE KEY-----\n", scope: ["https://www.googleapis.com/auth/drive"]});
resPromise.then(function(resData){
msg.headers = {};
msg.headers = {
"Authorization": `Bearer ${resData.access_token}`,
"Accept": "application/json"
};
node.warn(resData);
node.send([msg, null]);
}).catch(function(err){
node.error(err);
node.send([null, msg]);
});
Create Private key
Navigate to https://console.cloud.google.com/iam-admin/serviceaccounts and log in.
Select the project you want to connect with Google services.
Choose the service account from the list. Click on the vertical ellipses icon. Select Create key.
Select JSON in the pop-up window. Select Create.
A JSON file with the client email and the private key will get downloaded.
Copy the client_email and private_key from the JSON file and paste them in the function node in the Experience Designer flow.
Enable Google Drive API
Navigate to https://console.developers.google.com/apis/library/drive.googleapis.com
Make sure the project is selected and Enable the Google Drive API.
Â
You have successfully integrated Google drive with Orbita.
We recommend using the dynamic/content data to save the secret keys and retrieve the data using the Dynamic Manager node and pass it to function dynamically.