Skip to content

Simple and friendly examples showing you how to get setup to get archieml from gdocs

Notifications You must be signed in to change notification settings

joeyklee/archieml-sandbox

Repository files navigation

archieml-sandbox

archieml googledoc side by side with the json output

About

A small "sandbox" (a place to play) repo to demo one of the many ways of setup archieml with google auth library and google cloud. I'm hoping this is a helpful collection of examples and documentaiton to help you get up and running with google docs with archieml content in it. The goal is to keep the examples super simple so you can run with your own ideas! ❤

Overview

BEFORE you can run any of the examples in this repo, you'll need to do a few things:

  1. Get stuff setup in google cloud
  2. Get yourself setup to make auth'd requests from this repo
  3. Create a gdoc > add some archieml > and give your service account permissions to read that specific gdoc
    • follow these instructions here at step 3

It's as easy as 1,2,3 🎶! But seriously, all the auth and permissions stuff can be a drag and really hard to parse through especially if you're not familiar with google cloud and how they handle auth/permissions. Hopefully some of these docs are useful for you ❤

Once you've taken care of all the google cloud/auth/permissions nonsense, then you can run the demo app or run the simple example script to get a single doc




Before Getting Started: Set up Google Cloud and create a google doc with archieml in it

(process as of April 7, 2024)

Step 1 - Setup: Create your Google Cloud service account, enable billing, and google drive

  1. Create a new project:
    • go to google cloud console https://console.cloud.google.com/ > dropdown: select project > new project > project name: "name-it-whatever-you-want" > project id (under the input) click "edit" > project id: "name-it-whatever-you-want"
  2. create service account
  3. Set the role of the service account to: "viewer"
  4. enable billing
  5. enable google drive api --

Step 2 - Setup your app to be auth'd

After following the steps above, you need to decide how you want your app to get the application credentials to be able to read your files from google drive. You can follow these guides -- YOU ONLY NEED TO CHOOSE OF THESE

!!! You MUST complete one of the above so that the google-auth-library can successfully authenticate and get the authorizations it needs to talk to google drive!

Step 3 - Setup: create and permission your gdoc

Create and permission your google doc and add some archieml in!

gdoc with archieml text

  1. create a google doc
    • go to google drive drive.google.com > create a folder where you want to store your docs (e.g. a folder called "archieml") > create a new google doc
  2. add some archieml formatted text
    • e.g. copy and paste the value of textInGoogleDoc from the ./__fixtures/helloWorld.js file into your google doc
  3. update the docs permissions:
    • click: share > add the service account email you want to permission



Demo: A tiny node app that gets google docs by their ID

This is a tiny node/express app that uses the credentials from your service account to auth requests using the google-auth-library to get the text parsed from a google doc as json using archieml

Step 0 - Setup: google cloud stuff

Make sure you setup google cloud and have a google doc permissioned and ready to use. To do this:

  1. make sure you have completed: Before Getting Started: Set up Google Cloud and create a google doc with archieml in it

Step 1 - Setup: this repo

Assuming all went well above, this step gets your app setup to run.

Install the dependencies to run this app

cd archieml-sandbox
npm i

Step 2 - Run the app

This is a super simple node/express app that returns a parse JSON representation of a the content from a google doc.

npm run start
# see the magic at: http://localhost:3000

See your parsed gdoc by passing your gdoc id to: http://localhost:3000/doc/:docId, for example, if your google doc url looks like this:

https://docs.google.com/document/d/blah1blah2hello3yo4/edit

you can see the contents of that gDoc by making a request for blah1blah2hello3yo4

http://localhost:3000/doc/blah1blah2hello3yo4



Additional Examples

See /examples for other examples

get-single-doc.js

This example will just get a single doc log the parsed result. Make sure you've completed the steps above in the setup section so that you have the credentials needed to run this script.

# !!! first update `gdoc` id in the script with your own!
node -r dotenv/config examples/get-single-doc.js



Other ideas to demo

I have no idea when I'll get to these, but just logging down some ideas

  • Google Sheets: add examples pulling data from google sheets
  • Google Docs: add example using dropdowns
  • Google Docs: add example using suggestion mode



Credits

About

Simple and friendly examples showing you how to get setup to get archieml from gdocs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published