This is an advanced integration tutorial.

Pre-requisites (not covered here)

  • Pre-configured Integrations of Google Drive and Google Docs to be activated in your workspace settings

  • A template doc with variables set inside

You can also use our step templates to create the required steps

First Integration Step - Copy Document

POST:

https://www.googleapis.com/drive/v3/files/[DOCUMENTID]/copy/

Google Drive Pre-Configured integration

Second Integration Step - Send Response Body to Script for Parsing

POST

https://script.google.com/macros/s/AKfycbz3BmNDVtfbS8ol8zVn927zEOlUKdFeF-hGEgEl4YZ3hCuN0ENLdtz8q5kqImnYRNBE/exec


Body: Response from First Request

Third Integration Step - Replace Variables in newly created document

POST

https://docs.googleapis.com/v1/documents/[DATAREFERENCETOSECONDINTEGRATIONSTEP]:batchUpdate

Header: Content-Type: application/json

Google Docs Pre-Configured integration

Example body with 5 replaced variables in the document:

{
"requests": [{
"replaceAllText": {
"containsText": {
"text": "\{\{NAMEDERINSTANZ\}\}"
},
"replaceText": "{{instance_name}}"
}
}, {
"replaceAllText": {
"containsText": {
"text": "\{\{DOCVARIABLE1\}\}"
},
"replaceText": "DATAREFERENCEVARIABLE1"
}
}, {
"replaceAllText": {
"containsText": {
"text": "\{\{DOCVARIABLE2\}\}"
},
"replaceText": "DATAREFERENCEVARIABLE2"
}
}, {
"replaceAllText": {
"containsText": {
"text": "\{\{DOCVARIABLE3\}\}"
},
"replaceText": "DATAREFERENCEVARIABLE3"
}
}, {
"replaceAllText": {
"containsText": {
"text": "\{\{DOCVARIABLE4\}\}"
},
"replaceText": "DATAREFERENCEVARIABLE4"
}
}]
}

Fourth Integration Step - Receive Link to Document (Optional)

GET https://n962q5mp7c.execute-api.eu-central-1.amazonaws.com/g/util/google_document_link/[DATAREFERENCETOSECONDINTEGRATIONSTEP]

The response body will contain the link to the Google Docs version of the filled out template

Alternative option to receive the PDF link to the new document:

GET https://n962q5mp7c.execute-api.eu-central-1.amazonaws.com/g/util/google_document_pdf_link/[DATAREFERENCETOSECONDINTEGRATIONSTEP]

Fifth Integration Step - Move to Folder (Optional)

PATCH https://www.googleapis.com/drive/v3/files/[DATAREFERENCETOSECONDINTEGRATIONSTEP]?addParents=[PARENTID]

[ParentID] is the Id of the folder in Google Drive, which can be found in the URL once you're in that folder.

The brackets "[]" can always be removed

Did this answer your question?