> For the complete documentation index, see [llms.txt](https://docs.newbot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.newbot.io/use-newbot-framework-js/run-the-chatbot-on-nodejs.md).

# Run the chatbot on NodeJS

### What there is to know !

The execution of the chatbot is done on the built skill. Thus, reading the chapter on running the chatbot is useful for prodution. In development, NewBot CLI is running.

So, when you see the import `const mainSkill from './dist/server.js'`, it means that you have previously done the command `newbot build`

> If you want to build sources only for NodeJS, do `npx webpack`

### Installing NewBot

Let's first install the `newbot` module with `npm install newbot`

### Run

With NewBot CLI, code execution in the `bot` folder is hidden. This allows us to stay focused on conversational script design and chatbot skills

But how to execute ourselves, in a browser or server side?

Let's take an example :

```javascript
const { NewBot } = require('newbot')
// after `newbot build`
const mainSkill from './dist/node/bot'

const converse = new NewBot(mainSkill)
converse.exec('Hey', 'user id', (output, done) => {
    console.log(output)
    done()
})
```

The user runs the scenario with the `exec()` method. 1. The first parameter is the incoming message 2. The second parameter is the return function. It is called each time the conversational script sends data.

* `output` contains the chatbot message
* `done()` is a function to execute to continue the scenario

### Run with the native NLP

NodeJS side, you must put the path to the `model.nlp` file

```javascript
const { NewBot } = require('newbot')
// after `newbot build`
const mainSkill from './dist/node/bot'

const converse = new NewBot(mainSkill, {
    model: __dirname + '/model/mode.nlp'
})
converse.exec('Hey', 'user id', (output, done) => {
    console.log(output)
    done()
})
```
