TODO:
- have success messages at the bottom of each step to direct the user; they may be redundant to what we see in this file but they will be in the context of Townie on val.town and that may be easier than going back and forth between Townie and this file
- asdf
Use this file to guide you through the Glimpse setup process.
The instructions in this file are for you. I say that because it's important to distinguish them from the other files in this folder; those files are for Townie.
The prompts for you to enter into Townie are in code blocks, like this:
I'm a prompt for Townie
Townie will handle those prompts to write code on val.town, which—because it's on val.town—will be live. Townie will handle scaffolding the Val, user authentication, webhook authentication, caching, the front end, and metrics.
Once those bits are complete, you can add features til your heart's content.
- a val.town account
vt
is on your computer. If not, follow the instructions on the Github README
- Remix this Val on val.town, and give it a new name
- Use
vt
to clone the Val to your computer - Add a file called
vars.env
at the root of the Val - Add
vars.env
to the bottom of your .vtignore file, so that your environment variables aren't uploaded to val.town - Add all of the environment variables that this Val will use to
vars.env
; see "Environment variables required", below - Go to the Environment Variables section of your Val on val.town and import the
vars.env
file; oncevars.env
is uploaded, all of the environment variables are available to the Val and Townie, which means that val.town and Notion can connect to each other - Go to Townie, select this Val, and prompt Townie with this line:
Scaffold this Val with what you see in `/_townie/01-scaffold.md`
Important: These should already be in your vars.env
by the time you're reading this, and vars.env
should be in your vt.ignore
file. If you don't have a vars.env
file, or you don't have values for these variables, contact your administrator.
NOTION_API_KEY
- Your Notion integration API keyNOTION_WEBHOOK_SECRET
- Matches the X-API-KEY custom header coming from Notion webhooks to /tasks/* endpoint(s)GLANCE_DEMOS_DB_ID
- Your Notion database ID for demos, which are personalized to prospects and have unique URLsGLANCE_CONTENT_DB_ID
- Your Notion database ID for demo page content, which are compiled into demosGLANCE_INTERACTIONS_DB_ID
- Your Notion database ID for pageview metrics and the like
- In val.town, create a branch in your Val called
auth
- Go to Townie, select this Val, and then select the
auth
branch - Prompt Townie with this line:
Add auth to this Val with what you see in `/_townie/02-auth.md`
Work with Townie to make sure what appears at /
is correct. Once it's correct, move on to the next step.
- In val.town, merge
auth
intomain
- Delete the
auth
branch - Create a branch in your Val called
webhooks
- Go to Townie, select this Val, and then select the
webhooks
branch - Prompt Townie with this line:
Add webhook auth to this Val with what you see in `/_townie/03-webhooks.md`
- In Notion, add a button to a database row in the Glimpse Demos database
- Edit the automation on that button to be a webhook that hits
https://<branch subdomain url>/tasks/notion-webhook
- Add the custom header for webhook auth: Key:
X-API-KEY
and Value:<custom header value>
. (Find the value in theNOTION_WEBHOOK_SECRET
key invars.env
) - Save the button automation
- Click the button in Notion
- Go to the Logs in your Val and see the latest log statement, which should outline success or failure of your webhook and webhook auth
- Merge the
webhooks
branch intomain
- Delete the
webhooks
branch - Create a branch called
glimpse
- Go to Townie, select this Val, and then select the
glimpse
branch - Prompt Townie with this line:
Add an endpoint at `/views/glimpse/:id` by following the instructions in `/_townie/04-glimpse.md`
For now we will just have to trust that this new endpoint works. We will verify that's true in the next few steps.
- Prompt Townie with this line:
Add a route for `/glimpse/:id` by following the instructions in `/_townie/05-dupe.md`.
- Merge the
glimpse
branch into main - Delete the
glimpse
branch - Create a new branch called
url
Follow the instructions in `/_townie/06-url.md` to add an endpoint at `/tasks/url`.
- In Notion, add a button to a database row in the Glimpse Demos database called "Staging: set URL"
- Edit the automation on that button to be a webhook that hits
https://<branch subdomain url>/tasks/url
- Add the custom header for webhook auth: Key:
X-API-KEY
and Value:<custom header value>
. (Find the value in theNOTION_WEBHOOK_SECRET
key invars.env
) - Save the button automation
- Click the button in Notion
- You should see the
URL
property update with a URL to a Glimpse endpoint on val.town - If it fails, clues as to why are in the logs
- Go to the Logs in your Val and see the latest log statement
- If there's an error captured there, explain that to Townie
- Merge
url
into main - Delete the
url
branch - Create a new branch called "related"
Add related pages to the /glimpse/:id endpoint by following the instructions in `/_townie/07-related.md`
TODO: have Townie's success message at the end tell the user to update Notion automation with the URL on the main branch
- In Notion, click the URL in the
URL
property; it should not work. That URL is from a previous branch that we deleted. - Go to
main.tsx
and get the URL for this branch - Edit the automation on the "Set URL" button with that URL; make sure it incudes the
/tasks/url
endpoint - Save the button automation
- Click the button in Notion
- You should see the
URL
property update with a URL to a Glimpse endpoint on val.town - Click the new URL
- Authenticate
- CTRL+F
glimpseContent
-- that's the object that holds the related content you see in Notion
- Merge
related
into main - Delete the
related
branch - Create a new branch called
cache
Use the instructions in /_townie/08-cache.md to implement a cache for Glimpse demos at the `/glimpse/:id` endpoint
- merge
cache
intomain
- set cron interval to 1 minute
After merging into main
:
CRITICAL: Go to the Val Town web UI and set the cron schedule for /backend/crons/cache_glimpse_data.ts
to run every minute
Now that we have a responsive endpoint, we can iterate quickly on the front end without waiting for notion to respond and the JSON to render.
- Delete the
cache
branch - Create a new branch called
react
Use the instructions in `/_townie/09-react.md` to implement a React bootstrap for the `/glimpse/:id` endpoint
- test
/glimpse/:id
endpoint in thereact
branch - if it looks good, merge
react
intomain
- delete
react
branch
- Create a new branch called
html
- Go to townie and select the
html
branch - Enter this into townie:
TODO: make sure that the html instructions are clear about persisting the page layout with header including auth, sidenav, main content and footer.
use the instructions in `/_townie/10-html.md` to format the Notion data as HTML. Use this endpoint for testing: `/glimpse/20089f51-c349-803b-a940-edd14b011876
- test
/glimpse/:id
endpoint in thehtml
branch - if it looks good, merge
html
intomain
- delete
html
branch
- Create a new branch called
pdf-embeds
- Go to Townie and select the
pdf-embeds
branch - Enter this into Townie:
follow the instructions in `/_townie/11-embed.md` to implement rendering for certain embed blocks
The link is rendered as a button but it 404s. We need to implement the /glimpse/:id/pdf
route.
- Create a new branch called
pdf-route
- Go to Townie and select the
pdf-route
branch - Enter this into Townie:
follow the instructions in /_townie/PDF-ROUTE.md to implement rendering for certain embed blocks