Skip to content

Commit

Permalink
Fix Google Docs Integration (#2368)
Browse files Browse the repository at this point in the history
* add experimental and supporting text

* nodeId is used to create the hierarchy of the script.
By just passed nodeId[0], it was sending the object { id: x }, where "x" is the id number.
nodeId only needs the id value, x, rather than the key value pair.

* fix typos in scrub mobile numbers component

* remove private key from docs (was only for example purposes), but got in the way of gh push protection. replaced with 'aVeryLongPrivateKey'

* change the steps to get Google Docs integration working as it has changed the last 4 years.

* Revert "nodeId is used to create the hierarchy of the script."

This reverts commit 1ac88e1.

* nodeId is used to create the hierarchy of the script.
By just passing nodeId[0], it was sending the object { id: x }, where "x" is the id number.
nodeId only needs the id value, x, rather than the key value pair.
  • Loading branch information
engelhartrueben authored May 28, 2024
1 parent c736418 commit 1b76bee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 39 deletions.
54 changes: 19 additions & 35 deletions docs/HOWTO_IMPORT_GOOGLE_DOCS_SCRIPTS_TO_IMPORT.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
# HOWTO import interaction steps and canned responses from a Google Doc into Spoke
# HOWTO import interaction steps and canned responses from a Google Doc into Spoke **EXPERIMENTAL**

Note that in order to make the examples realistic, this document includes real IDs and secrets in the examples. The credentials and accounts connected with these examples will have been deleted before this file was pushed to Github.

It's a horrible idea to publish live secrets to Github. You should never do that. Please be sure to take adequate steps to protect your secrets.

## Setup
## Current Work in Progress (May 2024)

1. You must be logged in to Google.
1. Visit [this page](https://developers.google.com/docs/api/quickstart/nodejs) to start creating Google API credentials.
1. Click `Enable the Google Docs API`.
1. A dialog will appear.
1. Click `DOWNLOAD CLIENT CONFIGURATION`.
1. Open the downloaded file. The file will have a name like `credentials.json` or `credentials-2.json`.
1. The contents of the file will look like this:
This doc and associated feature is under construction/maintenence. Please consider the Google Docs Integration **experimental** for the time being and open an issue if you run into any issues.

```
{
"installed": {
"client_id": "971230067213-ochdc8fe93akq3ss04a3sqj3r2needvf.apps.googleusercontent.com",
"project_id": "quickstart-1552345943126",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "8gRezNEdmjh1CmobG8hS1Ljx",
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]
}
}
```
## Setup

8. Grab the value of the `project_id` key in the JSON in step 6. In this case it's `quickstart-1552345943126`. Note that we discard the quotes that surround it.
9. Go to [your Google API dashboard](https://console.developers.google.com/apis/credentials).
10. At the very top of that page, use the drop down at the top left to select the project whose name you grabbed in step 8. You will be shown a list of project names and IDs. Find your project by its ID and select it.
11. On that page, click `Create credentials` and then choose `Service account key`.
12. You'll be redirected to a page to create a service account.
1. You must be logged in to Google.
2. Visit [this page](https://developers.google.com/docs/api/quickstart/nodejs) to start creating Google API credentials.
3. Scroll down and click `Enable the Google Docs API`.
4. Follow the steps to endable Google Docs API.
5. On the top left of the page, click on "GoogleCloud", which will redirect you to the home page. Then, click `APIs & Services`.
6. Scroll down until you find `Google Docs API` and click it.
7. You'll be redirected to a page. On the top of the page, it will ask you to create a `New Service Account`, click it.
- Select `New service account` from the dropdown
- In `Servie account name` enter an arbirary name (`test` is fine, for example)
- In the `Role` Select `Project > Owner`
- Make sure the `JSON` radio button is selected (it should be selected by default)
- Click `Create`
- Wait.
13. Another file will be downloaded. The name of the file (which will have the extension `json`) will be displayed when the download is complete.
14. Open the file.
15. The contents will look like this:
- You may skip the opition "Grand Users access to this service account"
6. Return to the `Google Docs API` page, and on the left, click `Credentials` and then click `ADD KEY`.
- Set type to JSON and continue.
8. Another file will be downloaded. The name of the file (which will have the extension `json`) will be displayed when the download is complete.
9. Open the file.
10. The contents will look like this:

```
{
"type": "service_account",
"project_id": "quickstart-1552345943126",
"private_key_id": "1f029699545c3a00039b7ed0894f60d8bccfb970",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDLfJO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Ct7dEOE1f6moeotaCOD6L2FfbCumjx5mc5Ao+SSaWb5+s+1Cru\nyzAFa7lFdawR2FMRUuqTswpiCehU2wXvP+jo6ANgs+/DGLQ3Roe1BccmFOvW0FQx\nJdcAhZF6+qeDcIUk/Wg6GnPu6vkSaND1hMcQ+jw+XMVhaoqESabq+lR5cQKBgQC2\nqWkykOl++jSK8O9QghOry00dDsT/y7Wv0n7gpiq/Eyv3Khgh2TssDlxSQz4GH/C7\n4jj3d6oIihObGHFNPH5HZvx9e9J9EOezMn0imT+/HT8FmbQTLvWFUeZF+dQSIMs8\nnWpYnv4tmiEuDhZ/x3lN27ciPveAkDS5W7qM9YrJ6QKBgQDHenfweOPuZxFmfqqG\nao/GuNLdCn8c2ZJzUJR5NNpaXnUlDxEgOmaeAw9quRNtdVAVHBnPC4uFegc7VBcA\n9guK7uF7Q1rB1Ypw8qzuEBz6BDQ9zc4q026xrPXADVK6zqC/CvRhbYaTgykZaCJl\nozRrvrZDHjjgC5wC2+d278NcFQ==\n-----END PRIVATE KEY-----\n",
"private_key": "-----BEGIN PRIVATE KEY-----\naVeryLongPrivateKey\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "103778937997709997381",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
Expand All @@ -61,7 +45,7 @@ It's a horrible idea to publish live secrets to Github. You should never do that
16. Delete all the new lines so the entire contents of the file appears on a single line, and that line should not have a hard line end. It should be the only line in the file. It should look like this:

```
{ "type": "service_account", "project_id": "quickstart-1552345943126", "private_key_id": "1f029699545c3a00039b7ed0894f60d8bccfb970", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDLfJOh++1qhThG\nYE3IPpgdaNFGjmOU+xlBJJY6Ff1XIFmCD8qm2eVaByHVWk9o8ZBxFSYx/fgAiMYK\nJ8lun9hKZA7o7ecHQJt89j8QjLXlpfwuo11KZ+UAA46VqCtmnFuEtpZ5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wg6GnPu6vkSaND1hMcQ+jw+XMVhaoqESabq+lR5cQKBgQC2\nqWkykOl++jSK8O9QghOry00dDsT/y7Wv0n7gpiq/Eyv3Khgh2TssDlxSQz4GH/C7\n4jj3d6oIihObGHFNPH5HZvx9e9J9EOezMn0imT+/HT8FmbQTLvWFUeZF+dQSIMs8\nnWpYnv4tmiEuDhZ/x3lN27ciPveAkDS5W7qM9YrJ6QKBgQDHenfweOPuZxFmfqqG\nao/GuNLdCn8c2ZJzUJR5NNpaXnUlDxEgOmaeAw9quRNtdVAVHBnPC4uFegc7VBcA\n9guK7uF7Q1rB1Ypw8qzuEBz6BDQ9zc4q026xrPXADVK6zqC/CvRhbYaTgykZaCJl\nozRrvrZDHjjgC5wC2+d278NcFQ==\n-----END PRIVATE KEY-----\n", "client_email": "[email protected]", "client_id": "103778937997709997381", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-252%40quickstart-1552345943126.iam.gserviceaccount.com" }
{ "type": "service_account", "project_id": "quickstart-1552345943126", "private_key_id": "1f029699545c3a00039b7ed0894f60d8bccfb970", "private_key": "-----BEGIN PRIVATE KEY-----\naVeryLongPrivateKey\n-----END PRIVATE KEY-----\n", "client_email": "[email protected]", "client_id": "103778937997709997381", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-252%40quickstart-1552345943126.iam.gserviceaccount.com" }
```

17. In the Spoke `.env` file, or the environment variables section in Heroku settings, or in whatever your platform uses for configuration, create a key called `GOOGLE_SECRET` and set its value to the single line of text you created in step 16. (If you're using a `.env` file you must surround it by single quotes. If you're using Heroku you don't need to add quotes.) For AWS Lambda, there are [special deployment instructions](HOWTO_DEPLOYING_AWS_LAMBDA.md#environment-variable-maximum-4k)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export class CampaignConfig extends React.Component {
<p>
{scrubMobileOptional
? ""
: "This is a required step to lookup numbers you&rsquo;ve uploaded, but"}
FIRST you need to upload your contacts -- go to the Contacts section
and upload your list -- then check back here to look them up.
: "This is a required step to lookup numbers you have uploaded. "}
<br></br>But first, please go to the Contacts section
and upload your list, then check back here to look them up!
</p>
)}
{scrubState === states.C_NEEDS_RUN && (
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/lib/import-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const saveInteractionsHierarchyNode = async (
.returning("id");

for (const child of interactionsHierarchyNode.children) {
await saveInteractionsHierarchyNode(trx, campaignId, child, nodeId[0]);
await saveInteractionsHierarchyNode(trx, campaignId, child, nodeId[0].id);
}
};

Expand Down

0 comments on commit 1b76bee

Please sign in to comment.