Skip to content

Commit

Permalink
📖 DOCS(NOTION-92, #39) - Document for how to use notion-js in the bro…
Browse files Browse the repository at this point in the history
…wser
  • Loading branch information
alexcastillo committed Feb 6, 2020
1 parent 43a8462 commit 58321eb
Show file tree
Hide file tree
Showing 5 changed files with 580 additions and 75 deletions.
85 changes: 46 additions & 39 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
id: getting-started
title: Your First Application
title: Your First Node App
---
Welcome to Neurosity's NotionJS repository. To begin, you'll need to set up an account one time with Neurosity via [console.neurosity.co](consle.neurosity.co). Learn how to [create an account with Neurosity Developer Console](https://support.neurosity.co/hc/en-us/articles/360036196792).

Welcome to Neurosity's NotionJS documentation side. To begin, you'll need to set up an account one time with Neurosity via [console.neurosity.co](consle.neurosity.co). Learn how to [create an account with Neurosity Developer Console](https://support.neurosity.co/hc/en-us/articles/360036196792).

## Prerequisites

To download the necessary tools, clone the repository, and install dependencies via `npm`, you need network access.
To download the necessary tools, clone the repository, and install dependencies via `npm`, you need network access.

### NPM

Expand All @@ -24,7 +25,7 @@ We'll be using [VSCode](https://code.visualstudio.com/download) to program this

### Tutorial Repository

Want to see the complete project befor reading anymore? You can view all the code from this project in it's [repository on Github](https://github.com/neurosity/app-hello-world-notion-js).
Want to see the complete project before reading anymore? You can view all the code from this project in it's [repository on Github](https://github.com/neurosity/app-hello-world-notion-js).

## Setup your Project

Expand All @@ -44,13 +45,14 @@ npm init
```

You'll need to run through the initial questions:

```bash
package name: (hello-world)
version: (1.0.0)
package name: (hello-world)
version: (1.0.0)
description: My first application using Notion
entry point: (index.js)
test command:
git repository:
entry point: (index.js)
test command:
git repository:
keywords: notion
author: Hans Berger
license: (ISC) MIT
Expand All @@ -60,7 +62,7 @@ license: (ISC) MIT
<img alt="Initial set up of NPM project" src="assets/images/tutorial/npm_init.png">
</p>

Next you'll want to launch a VSCode window for the newly created project.
Next, you'll want to launch a VSCode window for the newly created project.

```bash
code .
Expand Down Expand Up @@ -96,7 +98,7 @@ The first thing we want to do is add a file called `.gitignore` to tell git to i
node_modules
```

On macOS, we'll go ahead an add another commonly ignored file:
On MacOS, we'll go ahead and add another commonly ignored file:

```
.DS_Store
Expand Down Expand Up @@ -126,7 +128,7 @@ Importing libraries in Node is quite simple, all you have to do is add the follo

```js
const { Notion } = require("@neurosity/notion");
require('dotenv').config();
require("dotenv").config();
```

<p align="center">
Expand All @@ -135,7 +137,7 @@ require('dotenv').config();

### Add start script to package.json

Now head over to the file called `package.json`. The `package.json` is at the core of every Node package. **Ignore the file called `package-lock.json`, it's automatically generated.**
Now head over to the file called `package.json`. The `package.json` is at the core of every Node package. **Ignore the file called `package-lock.json`, it's automatically generated.**

Find the section called `"scripts"` and add a property called `"start"` that will start the node process:

Expand All @@ -155,9 +157,7 @@ Your `package.json` will look like below once added:
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"notion"
],
"keywords": ["notion"],
"author": "Hans Berger",
"license": "MIT",
"dependencies": {
Expand Down Expand Up @@ -199,14 +199,20 @@ To verify that the variables are not blank, we could add a function to check for

```js
const verifyEnvs = (email, password, deviceId) => {
const invalidEnv = (env) => {
return (env === "" || env === 0);
}
if (invalidEnv(email) || invalidEnv(password) || invalidEnv(deviceId)) {
console.error("Please verify deviceId, email and password are in .env file, quitting...");
process.exit(0);
const invalidEnv = env => {
return env === "" || env === 0;
};
if (
invalidEnv(email) ||
invalidEnv(password) ||
invalidEnv(deviceId)
) {
console.error(
"Please verify deviceId, email and password are in .env file, quitting..."
);
process.exit(0);
}
}
};
verifyEnvs(email, password, deviceId);

console.log(`${email} attempting to authenticate to ${deviceId}`);
Expand Down Expand Up @@ -254,16 +260,17 @@ We need to use an [`async/await`](https://javascript.info/async-await) paradigm

```js
const main = async () => {
await notion.login({
email,
password
})
.catch(error => {
console.log(error);
throw new Error(error);
});
await notion
.login({
email,
password
})
.catch(error => {
console.log(error);
throw new Error(error);
});
console.log("Logged in");
}
};

main();
```
Expand All @@ -283,7 +290,7 @@ Now that you are authenticated, print out hello world when you're calm increases
Add the following code to your main() function after login.

```js
notion.calm().subscribe((calm) => {
notion.calm().subscribe(calm => {
if (calm.probability > 0.3) {
console.log("Hello World!");
}
Expand All @@ -300,18 +307,18 @@ Your index.js file is now ready to print `Hello World!`

Head over to the [Developer Console](https://console.neurosity.co) and train Left Hand Pinch. [Learn how to train an imagined movement thought](https://support.neurosity.co/hc/en-us/articles/360036344012-Imagined-thought-training). Do at least 15 trials.

When we write code to interact with Notion, we use camel case, so Left Hand Pinch in code is `leftHandPinch`.
When we write code to interact with Notion, we use camel case, so Left Hand Pinch in code is `leftHandPinch`.

Now that the `leftHandPinch` thought is trained, you'll be able to use load it into your Notion for use.
Now that the `leftHandPinch` thought is trained, you'll be able to use load it into your Notion for use.

### Kinesis Subscription

In the `index.js` file we can remove the `calm` subscription from above and replace it with the code below.
In the `index.js` file we can remove the `calm` subscription from above and replace it with the code below.

Check out the [Kinesis guide](https://docs.neurosity.co/docs/api/kinesis) or [Kinesis API docs](https://docs.neurosity.co/docs/reference/interfaces/kinesis).

```js
notion.kinesis("leftHandPinch").subscribe((intent) => {
notion.kinesis("leftHandPinch").subscribe(intent => {
console.log("Hello World!");
});
```
Expand All @@ -324,10 +331,10 @@ Your `index.js` file should look like:

## Conclusion

Developing with Neurosity Notion can be a lot of fun! There are two main types of thought processes that Notion detects, intent and background. The forground we consider to be the `kinesis()` where you're intending to do something and the background is `calm()` or `focus()` that occurs in the background of the mind.
Developing with Neurosity Notion can be a lot of fun! There are two main types of thought processes that Notion detects, intent and background. The foreground we consider to be the `kinesis()` where you're intending to do something and the background is `calm()` or `focus()` that occurs in the background of the mind.

### Dive into development

We're looking for great developers to help us better and better trainings, so head over to the [training guide](https://docs.neurosity.co/docs/guides/training) to learn how to build your own training application.
We're looking for talented developers to help us improve the kinesis training. So, head over to the [training guide](https://docs.neurosity.co/docs/guides/training) and learn how to build your own training module.

If you're looking for exact API references, check out the [API section](/docs/reference) of these docs!
46 changes: 27 additions & 19 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,50 @@
id: overview
title: NotionJS
---
NotionJS is built with privacy and ease of use in mind. Our dream is to build the next major computing platform, a new system, that learns from you via symbiotic computing. A computing platform is a place filled with applications built by millions of developers. The first step in building this new platform is to make applications that add value. To make applications quickly, easily, and accessible by any number of clients, we use NotionJS. This repository is used by the Neurosity team to build our very own applications. We have a dream that some of the best apps will be written by people outside of Neurosity.

NotionJS is built with privacy and simplicity in mind. Our mission is to build the next major computing platform. A platform that learns from you. The first step in building this platform is to make applications that add value to people's lives.

We've created NotionJS to empower developers to build neuro-driven and accessible apps, quickly and easily.

We know some of the best apps will be written by the community, so we've open-sourced NotionJS to provide visibility and transparency to our users.

This documentation describes:

* How to authenticate, query, train, and use a Notion
* How to take advantage of Neurosity's NotionJS
* Where to find guides and code samples to help get you started
- How to authenticate, query, train, and use a Notion
- How to take advantage of Neurosity's NotionJS
- Where to find guides and code samples to help you get started

Jump right over to building your first:

Jump right over to [building your first application with Notion](getting-started).
- [Node App](getting-started)
- [Web App](tutorials/your-first-web-app)

## What can NotionJS do?

Here are some examples of what you can achieve with NotionJS:

* Authenticate and access a Notion - [Authentication](api/authentication)
* Query device status - [Info](api/info) or [Status](api/status)
* Check signal quality - [Signal Quality](api/signal-quality)
* Peer into mental states of a person - [Calm](api/calm) or [Focus](api/focus)
* Train a new thought - [Training](guides/training)
* Use a trained thought for control - [Kinesis](api/kinesis)
- Authenticate and access a Notion - [Authentication](api/authentication)
- Query device status - [Info](api/info) or [Status](api/status)
- Check signal quality - [Signal Quality](api/signal-quality)
- Peer into mental states of a person - [Calm](api/calm) or [Focus](api/focus)
- Train a new thought - [Training](guides/training)
- Use a trained thought for control - [Kinesis](api/kinesis)

## How to use NotionJS?

Building a good application with NotionJS can take a lot of effort. Here is what each section of the API docs can help you with:

* **Get Started** teaches fundamental concepts for using NotionJS
* **Guides** includes in-depth guides on various NotionJS development topics, such as [ethics](guides/ethics) and [training](guides/training).
* **References** contains exhaustive references for the [NotionJS API](docs/api).
- **Get Started** teaches fundamental concepts for using NotionJS
- **Guides** includes in-depth guides on various NotionJS development topics, such as [ethics](guides/ethics) and [training](guides/training).
- **References** contains exhaustive references for the [NotionJS API](docs/api).

## Looking for help?

If you have questions for extension development, try asking on:

* [Online community](https://support.neurosity.co/hc/en-us/community/topics): There are general discussions and feature requests taking place here.
* [Stack Overflow](https://stackoverflow.com/questions/tagged/notion-js): There are no questions yet, but we hope to create thousand of questions tagged with `notion-js`.
* [Discord](https://discord.gg/E4dvX6g): Public chatroom for NotionJS developers. Some Neurosity team members chime in conversations.
* [Knowledge Base](support.neurosity.co): There are over a dozen articals for getting started and developing with NotionJS.
- [Online community](https://support.neurosity.co/hc/en-us/community/topics): There are general discussions and feature requests taking place here.
- [Stack Overflow](https://stackoverflow.com/questions/tagged/notion-js): There are no questions yet, but we hope to build a community-driven knowledge base using the `notion-js` tag.
- [Discord](https://discord.gg/E4dvX6g): Public chatroom for NotionJS developers. Some Neurosity team members chime in conversations.
- [Knowledge Base](support.neurosity.co): There are over a dozen articles for getting started and developing with NotionJS.

To provide feedback on the documentation, create new issues at [Neurosity/notion-js](https://github.com/neurosity/notion-js). If you have NotionJS questions that you cannot find an answer for, or issues with the NotionJS API, please open new issues at [Neurosity/notion-js](https://github.com/neurosity/notion-js) as well.
To provide feedback on the documentation, create new issues at [Neurosity/notion-js](https://github.com/neurosity/notion-js). If you have NotionJS questions, or issues with the NotionJS API, please open new issues at [Neurosity/notion-js](https://github.com/neurosity/notion-js) as well.
Loading

0 comments on commit 58321eb

Please sign in to comment.