> For the complete documentation index, see [llms.txt](https://docs.nmreddy.me/diy-portfolio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nmreddy.me/diy-portfolio/creating-env-variables.md).

# Creating env variables

Steps to create the environment variables needed for the functioning of the contact form and the backend edge function.

### Introduction

The contact page on the website is connected to an edge function that requires three env variables - NOTION\_API\_KEY, NOTION\_DB\_ID, NOTION\_USER\_ID to store the contact enquiries and notify you about the enquiries.

Follow the steps below to create the env variables and then paste them in your deployment settings as described in the deployment documentation.

### Creating a Notion Account

1. Go to <https://notion.so>
2. Create your account by clicking on Get Notion free.

***

### Creating NOTION\_API\_KEY env variable

1. Navigate to <https://developers.notion.com/> and login with your notion account.
2. Click “View my integrations”.

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FDAlJlOeQmIhmj0cZyK5n%2Fimage-003.png?alt=media&amp;token=d78fe00d-baac-4925-91a3-ee798c903042" alt=""><figcaption></figcaption></figure>
3. Click “New integration”

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2Fq92kwSHqEKSR36FjYQbK%2Fimage-004.png?alt=media&amp;token=835c8f7c-9109-42a9-85ba-d83b8729cf42" alt=""><figcaption></figcaption></figure>
4. Give  the integration a name of your choice.

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2Frs73rxvR9qXUPOf9KEIO%2Fimage-005.png?alt=media&amp;token=2b50da7e-7903-4d29-a51c-d3a63738c794" alt=""><figcaption></figcaption></figure>
5. Click submit.&#x20;

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FQiVQvJOmqnlDNUqNUBVc%2Fimage-006.png?alt=media&amp;token=bffb4735-f042-4739-86aa-2b8f2027869a" alt=""><figcaption></figcaption></figure>
6. Click “Capabilities”

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2F6AQO3PNzihHwiHtAjM0n%2Fimage-007.png?alt=media&amp;token=9b54f942-f354-4066-8270-644546279f5a" alt=""><figcaption></figcaption></figure>
7. Click “Read user information without email addresses”

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FVFuea0FoU8mrxhkpmyE4%2Fimage-008.png?alt=media&amp;token=0c552f60-9e3c-4db5-8269-13fd6f110f40" alt=""><figcaption></figcaption></figure>
8. Click “Save changes”

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FfUfxfYwHhKwRVu56dSJY%2Fimage-009.png?alt=media&amp;token=2b1e736e-c034-4f14-944e-af3adb25507e" alt=""><figcaption></figcaption></figure>
9. Go back to “Secrets”

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FkUjqwWZNgEJxnHGMP9gd%2Fimage-010.png?alt=media&amp;token=9f58448d-6079-458f-bacd-bd334bf804d5" alt=""><figcaption></figcaption></figure>
10. Click on “Show” and then “Copy”

    <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2F9F96clnvZolX9BhVfEQB%2Fimage-011.png?alt=media&amp;token=b3d51e9c-2ffc-4cd3-a491-d7f6731992f4" alt=""><figcaption></figcaption></figure>
11. This secret is your NOTION\_API\_KEY value. Paste it in your deployment environment variables.

***

### Creating NOTION\_DB\_ID env variable

1. Go to <https://notion.so> and login with your Notion account.

2. Create a new page, with a table.

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FVyJk4LWjuwnt0ZKDQmGN%2Fimage-002.png?alt=media&amp;token=51e448cd-f05a-4b8a-98b2-4de1768b6c7c" alt=""><figcaption><p>Creating a new page</p></figcaption></figure>

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2F6KhkFo0mhS0S5ufSQUGC%2Fimage-003.png?alt=media&amp;token=cc6df7bb-7d47-47ec-b7e5-1f509c17e287" alt=""><figcaption><p>Adding a table to the new page</p></figcaption></figure>

3. Create a new data source by entering the name and clicking on new database in the next page as shown below.

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FabbVzZrX227d9CZWJdYD%2Fimage-004.png?alt=media&amp;token=8533a990-8fb2-4716-a8c2-66bcb4f06a3f" alt=""><figcaption></figcaption></figure>

4. Change the heading of the 'Name' column to 'Subject'. This is the title column for the new pages.

   ![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FDjbFZQrin2ax1IjMdLqh%2Fimage-005.png?alt=media\&token=f5a54c3c-9c13-4a55-8f40-8a1c978f3ed3)       ![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2F5Tmqrv6T3L59Sa4pjIJj%2Fimage-006.png?alt=media\&token=07816ee2-937a-4f82-ad87-c2f4b38836bc)

5. Delete the Tags column.

6. Add the following new columns by clicking on the plus button.![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FHi83Q5iABgS979BWtpV1%2Fimage-011.png?alt=media\&token=31eb4432-96e9-4303-8443-39c10b6ef0b5)![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2Fy8yfYdJKwl9vGF20XO9E%2Fimage-009.png?alt=media\&token=15232252-b3ca-4683-9c0e-473ff49fa98d)

<table data-full-width="false"><thead><tr><th>Property</th><th>Type</th></tr></thead><tbody><tr><td>Name</td><td>Text</td></tr><tr><td>Email</td><td>Email</td></tr><tr><td>Message</td><td>Text</td></tr><tr><td>Date</td><td>Date</td></tr><tr><td>Mention</td><td>Person</td></tr></tbody></table>

The final table should look similar to the below table.

<figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FQhr67qMHJcDuxAztWSUK%2Fimage.png?alt=media&amp;token=4bce6249-3727-487d-900b-f6f6f1806802" alt=""><figcaption><p>Final Enquiries Table</p></figcaption></figure>

7. Click on more and then Add Connections → select the integration you created → Confirm. This step is mandatory to allow the integration to fill the data in the table.

   ![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FD9mk6wI6C7wQ91bBFmoB%2Fimage-002.png?alt=media\&token=ecb76bdc-b9c3-4fd0-a880-97d36c00a16b)![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2F7e9Oo5TEkDuI9dOFwxRu%2Fimage-004.png?alt=media\&token=4b45f2c6-9079-4148-8d38-b78c293a5120)
8. Then open the table in a new view.

   ![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FxgXMK0MceP2n2ycjaYO6%2Fimage-002.png?alt=media\&token=6c39efe6-c4f8-4a04-8aa5-b40490f67414)![](https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2Fi8TZqvGzUW3j2Cu1k6Wd%2Fimage-003.png?alt=media\&token=4c3d2386-d0c1-488c-b9dd-ca136d1ae8bc)
9. Copy the URL of the opened table. It should look as follows:

   <https://www.notion.so/username/87e015e43e7f4c9ebb6fb9612f644556?v=\\><VIEWID>
10. The ID after username/ and before ?v= is the NOTION\_DB\_ID. Paste it in your deployment environment variables.

***

### Creating NOTION\_USER\_ID env variable

1. Navigate to <https://reqbin.com/>
2. Paste `https://api.notion.com/v1/users` in the URL field.
3. Go to Authorization tab and paste your [NOTION\_API\_KEY ](#creating-notion_api_key-env-variable)in the Token field.

   <figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2F2n6zLaCPvPw0RJ4PYPx1%2Fimage-005.png?alt=media&amp;token=ec81afbf-2cad-420f-9029-91a541136a3b" alt=""><figcaption></figcaption></figure>
4. Click on the Headers tab and paste `Notion-Version: 2022-06-28.`
5. Click Send.
6. Copy the ID of the user that **matches with your name, not the integration name. Verify that the type is person and not bot.**

<figure><img src="https://3388015083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNF5LCNNEp2j2Ly4sFR0G%2Fuploads%2FZNFBO9S9A2BL39R0OWJK%2Fimage-008.png?alt=media&amp;token=30b8796f-9076-4fba-b698-f9b32aa13980" alt=""><figcaption></figcaption></figure>

7. This copied ID is your NOTION\_USER\_ID.
