This project was created by Dobson Dunavant.
- Next.js (TypeScript, Pages Router) project bootstrapped with
create-next-app
- Tailwind CSS
- next-themes
- OpenAI's Assistant API v2
- Custom Notion CMS integration
Follow these steps to set up the project on your local machine:
-
Clone the Repository
git clone https://github.com/your-repo-url.git
-
Install Dependencies
Navigate to the project directory and run:
npm install
-
Set Up Environment Variables
-
Duplicate the
.env.example
file and rename it to.env
in the root directory:cp .env.example .env
-
Open the
.env
file and add your values to each environment variable as specified in the Environment Variables Setup section.
-
-
Start the Development Server
npm run dev
-
View in Browser
Open http://localhost:3000 in your web browser to see the application.
The project requires several environment variables to function correctly. Below are the variables and instructions on how to obtain their values:
-
Description: Your Google Analytics Tracking ID, used for website analytics.
-
How to Obtain:
- Sign in to your Google Analytics account.
- Click on Admin in the lower-left corner.
- Under the Property column, select the property you want to use.
- Click on Tracking Info > Tracking Code.
- Your Tracking ID will be at the top of the page, formatted like
UA-XXXXXXXXX-X
orG-XXXXXXXXXX
.
-
Set in
.env
:NEXT_PUBLIC_GA_TRACKING_ID=YOUR_GOOGLE_ANALYTICS_TRACKING_ID
-
Description: API key for accessing Notion's official API.
-
How to Obtain:
- Visit Notion's My Integrations.
- Click on + New Integration.
- Fill in the required details (name, associated workspace) and click Submit.
- After creation, you'll see an Internal Integration Token. This is your API key.
-
Set in
.env
:NOTION_API_KEY=YOUR_NOTION_API_KEY
-
Description: The unique ID of your Notion database used as a CMS.
-
How to Obtain:
- Open the database page in Notion.
- Look at the URL in your browser; it will look something like
https://www.notion.so/YourWorkspace/Database-Name-xxxxxxxxxxxxxxxxxxxxxx
. - The part after the last slash and before the question mark (
?
) is your Database ID.- Example: In
https://www.notion.so/YourWorkspace/Database-Name-**abcdef1234567890abcdef1234567890**
, the bolded part is the Database ID.
- Example: In
-
Set in
.env
:NOTION_DATABASE_ID=YOUR_NOTION_DATABASE_ID
-
Description: API key for accessing OpenAI services, necessary for chatbot functionality.
-
How to Obtain:
- Log in or sign up at OpenAI's Platform.
- Navigate to the API Keys page.
- Click on Create new secret key.
- Copy the generated API key.
-
Set in
.env
:OPENAI_API_KEY=YOUR_OPENAI_API_KEY
-
Description: Legacy token used for certain Notion integrations. Required only if you're using unofficial APIs or specific features.
-
How to Obtain:
- Warning: Accessing
token_v2
may violate Notion's terms of service. Proceed only if you're certain you need this and understand the implications.
- Log in to Notion in your web browser.
- Open the browser's developer tools (usually by pressing
F12
). - Navigate to the Application (Chrome) or Storage (Firefox) tab.
- Under Cookies, find
token_v2
. - Copy its value.
- Warning: Accessing
-
Set in
.env
:NOTION_TOKEN_V2=YOUR_NOTION_TOKEN_V2
-
Description: The active user ID for Notion, sometimes needed alongside
token_v2
. -
How to Obtain:
- In the same browser developer tools where you found
token_v2
, look for a cookie namednotion_user_id
. - Copy its value.
- In the same browser developer tools where you found
-
Set in
.env
:NOTION_ACTIVE_USER=YOUR_NOTION_ACTIVE_USER
To personalize the project, make the following core changes:
-
Update Content
- Most unique content is stored within
{componentName}Data.ts
files located in each component's folder. - Update these files with your own content to reflect your project's information.
- Most unique content is stored within
-
Modify Themes
- Change global themes by editing the
tailwind.config.js
file. - Customize colors, fonts, and other design elements as desired.
- Change global themes by editing the
-
Handle Vanta.js Backgrounds Carefully
- Vanta.js provides animated backgrounds that can be resource-intensive.
- Use source control diligently (e.g., commit frequently) when modifying these to easily revert if issues arise.
If you prefer not to use the chatbot, remove or comment out the following imports and usages in components/Navbar.tsx
:
-
Imports to remove/comment out:
import ChatbotFixedButton from '...'; import ChatbotNavbarButton from '...'; import ChatbotModal from '...';
-
Usages to remove/comment out:
<ChatbotFixedButton /> <ChatbotNavbarButton /> <ChatbotModal />
To enable the chatbot functionality, complete the following steps:
-
Obtain OpenAI API Access
- Ensure you have a premium OpenAI account with API access.
- As of 2023, you may need to request access or subscribe to a paid plan.
-
Create an OpenAI Project and API Key
- Follow the steps under
OPENAI_API_KEY
to generate your API key.
- Follow the steps under
-
Configure Environment Variables
- Make sure your
OPENAI_API_KEY
is set in the.env
file as detailed above.
- Make sure your
-
Update Structured Data
- Modify
content/structuredData.json
with the content you want the chatbot to reference during conversations. - Note: Adding a large amount of content may slow down response times, as the current setup doesn't scale well with larger datasets.
- Modify
-
Vercel
- Vercel is highly recommended for its ease of configuration and deployment.
- Features include analytics, optimization, and automatic redeployment upon changes to the
main
branch. - Visit Vercel to get started.
-
GitHub Pages
- Alternatively, you can deploy using GitHub Pages if you prefer a simpler setup.
-
Set Environment Variables
- Remember to set all your environment variables (e.g.,
OPENAI_API_KEY
,NOTION_API_KEY
, etc.) in your deployment platform's settings. - For Vercel:
- Go to your project dashboard on Vercel.
- Navigate to Settings > Environment Variables.
- Add each variable and its corresponding value.
- Remember to set all your environment variables (e.g.,
-
Deploying with Vercel
- The easiest way to deploy your Next.js app is through the Vercel Platform.
- After connecting your GitHub repository, Vercel will automatically deploy your project.
-
Additional Resources
- Refer to the Next.js deployment documentation for more details.
- Vercel's documentation also provides comprehensive guides.
Feel free to reach out if you have any questions or need further assistance!